Jump to content

FtpClient: Difference between revisions

From auWiki
New page: {{RightTOC}} C# class that connects to an FTP server. =====Namespace===== au.util.io =====Hierarchy===== * System.Object ** au.util.io.FtpClient ==Usage== Create a <code>new FtpClient...
 
m Public Functions: rename Functions -> Methods
 
(2 intermediate revisions by the same user not shown)
Line 14: Line 14:
* string Message = Last message received from the FTP server.
* string Message = Last message received from the FTP server.


==Public Functions==
==Public Methods==
===new FtpClient===
===new FtpClient===
<code>FtpClient(string hostname, int port)</code>
<code>FtpClient(string hostname, int port)</code>
Creates an FTP client which can connect to the specified FTP server.
Creates an FTP client which can connect to the specified FTP server.
* hostname = Name of FTP server to connect to.
* hostname = Name of FTP server to connect to.
Line 23: Line 24:
===Open===
===Open===
<code>bool Open(string username, string password)</code>
<code>bool Open(string username, string password)</code>
Attempts to open the FTP connection and login with the credentials provided.
Attempts to open the FTP connection and login with the credentials provided.
* username = Username to log in to FTP server with.
* username = Username to log in to FTP server with.
Line 34: Line 36:
===SendCommand===
===SendCommand===
<code>void SendCommand(string command)</code>
<code>void SendCommand(string command)</code>
Sends a command to the FTP server.
Sends a command to the FTP server.
* command = Command to send to the FTP server.
* command = Command to send to the FTP server.
Line 39: Line 42:
===CWD===
===CWD===
<code>bool CWD(string path)</code>
<code>bool CWD(string path)</code>
Change working directory on the FTP server.
Change working directory on the FTP server.
* path = Directory to change to.
* path = Directory to change to.
Line 45: Line 49:
===SendFile===
===SendFile===
<code>bool SendFile(string filename, [[FtpTransferType]] type)</code>
<code>bool SendFile(string filename, [[FtpTransferType]] type)</code>
Sends a file to the FTP server.
Sends a file to the FTP server.
* filename = Full client path to the file to send.
* filename = Full client path to the file to send.
Line 52: Line 57:
===SendText===
===SendText===
<code>bool SendText(string filename, string contents)</code>
<code>bool SendText(string filename, string contents)</code>
Sends a string to the FTP server as a file.
Sends a string to the FTP server as a file.
* filename = File name to create on FTP server (no path).
* filename = File name to create on FTP server (no path).

Latest revision as of 11:52, 18 July 2007

C# class that connects to an FTP server.

Namespace

au.util.io

Hierarchy
  • System.Object
    • au.util.io.FtpClient

Usage

Create a new FtpClient object with the FTP server name and port number, then use Open() to open the FTP connection and login. Change directories with CWD() and send data with SendFile() or SendText(), then close the connection with Bye().

Public Properties

  • int Code = Last response code received from the FTP server.
  • string Message = Last message received from the FTP server.

Public Methods

new FtpClient

FtpClient(string hostname, int port)

Creates an FTP client which can connect to the specified FTP server.

  • hostname = Name of FTP server to connect to.
  • port = Port of FTP server to connect to.

Open

bool Open(string username, string password)

Attempts to open the FTP connection and login with the credentials provided.

  • username = Username to log in to FTP server with.
  • password = Password to log in to FTP server with.
  • @return = True if the connection is opened.

Bye

void Bye() Closes the FTP connection.

SendCommand

void SendCommand(string command)

Sends a command to the FTP server.

  • command = Command to send to the FTP server.

CWD

bool CWD(string path)

Change working directory on the FTP server.

  • path = Directory to change to.
  • @return = True if successful.

SendFile

bool SendFile(string filename, FtpTransferType type)

Sends a file to the FTP server.

  • filename = Full client path to the file to send.
  • type = Type of FTP transfer to use.
  • @return = True if file is sent.

SendText

bool SendText(string filename, string contents)

Sends a string to the FTP server as a file.

  • filename = File name to create on FTP server (no path).
  • contents = Contents of the file to create.
  • @return = True if file is sent.