Skip to content

FTPS Proxies

Robinicks edited this page Feb 5, 2020 · 19 revisions

API

FAQs

How do I login with an FTP proxy?

Create a new instance of one of the proxy classes and then use any of the available API to control the connection. For example:

// create an FTP client connecting through a HTTP 1.1 Proxy
var proxy = new ProxyInfo(){
    Address = new Uri("http://myproxy.com/"),
};
FtpClient client = new FtpClientHttp11Proxy(proxy);
client.Host = "123.123.123.123";
client.Credentials = new NetworkCredential("david", "pass123");

// begin connecting to the server
client.Connect();

// get a list of files and directories in the "/htdocs" folder
foreach (FtpListItem item in client.GetListing("/htdocs")) {
	
	// if this is a file
	if (item.Type == FtpFileSystemObjectType.File){
		
		// get the file size
		long size = client.GetFileSize(item.FullName);
		
		// calculate a hash for the file on the server side (default algorithm)
		FtpHash hash = client.GetHash(item.FullName);
	}
	
	// get modified date/time of the file or folder
	DateTime time = client.GetModifiedTime(item.FullName);
	
}

// upload a file
client.UploadFile(@"C:\MyVideo.mp4", "/htdocs/MyVideo.mp4");

// rename the uploaded file
client.Rename("/htdocs/MyVideo.mp4", "/htdocs/MyVideo_2.mp4");

// download the file again
client.DownloadFile(@"C:\MyVideo_2.mp4", "/htdocs/MyVideo_2.mp4");

// delete the file
client.DeleteFile("/htdocs/MyVideo_2.mp4");

// disconnect! good bye!
client.Disconnect();
Clone this wiki locally