GetPut - FTP download/upload (.NET Compact Framework)

Sample utility for uploading and downloading files using FTP.

C#

// create Ftp object, connect to the server and login
Ftp ftp = new Ftp();
ftp.Connect(hostname);
ftp.Login(username, password);

// set transfer type to binary
ftp.TransferType = FtpTransferType.Binary;

// upload file and display number of bytes transferred
long bytes = ftp.PutFile(localPath, remotePath);
Console.WriteLine("Transfered {0} bytes.", bytes);

// disconnect
ftp.Disconnect();

VB.NET

' create Ftp object, connect and log in
Dim ftp As New Ftp()
ftp.Connect(hostname)
ftp.Login(username, password)

' set transfer type to binary
ftp.TransferType = FtpTransferType.Binary

' upload file and display number of bytes transferred
Dim bytes As Long = ftp.PutFile(localPath, remotePath)
Console.WriteLine("Transfered {0} bytes.", bytes)

' disconnect
ftp.Disconnect()