FtpClient

From auWiki
Jump to: navigation, search

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.