How to check if an FTP directory exists

Basically trapped the error that i receive when creating the directory like so. private bool CreateFTPDirectory(string directory) { try { //create the directory FtpWebRequest requestDir = (FtpWebRequest)FtpWebRequest.Create(new Uri(directory)); requestDir.Method = WebRequestMethods.Ftp.MakeDirectory; requestDir.Credentials = new NetworkCredential(“username”, “password”); requestDir.UsePassive = true; requestDir.UseBinary = true; requestDir.KeepAlive = false; FtpWebResponse response = (FtpWebResponse)requestDir.GetResponse(); Stream ftpStream = response.GetResponseStream(); ftpStream.Close(); response.Close(); … Read more

How to send arbitrary FTP commands in C#

I don’t think it can be done with FtpWebRequest… The only way to specify a FTP command is through the Method property, and the documentation states : Note that the strings defined in the WebRequestMethods.Ftp class are the only supported options for the Method property. Setting the Method property to any other value will result … Read more

System.Net.FtpWebRequest GetDateTimestamp example

Yep – thats pretty much what I ended up with. I went with something like this request = FtpWebRequest.Create(“ftp://ftp.whatever.com/somefile.txt”); request.Method = WebRequestMethods.Ftp.GetDateTimestamp; request.Proxy = null; using (FtpWebResponse resp = (FtpWebResponse)request.GetResponse()) { Console.WriteLine(resp.LastModified); }

FtpWebRequest Download File

I know this is an old Post but I am adding here for future reference. Here is a solution that I found: private void DownloadFileFTP() { string inputfilepath = @”C:\Temp\FileName.exe”; string ftphost = “xxx.xx.x.xxx”; string ftpfilepath = “/Updater/Dir1/FileName.exe”; string ftpfullpath = “ftp://” + ftphost + ftpfilepath; using (WebClient request = new WebClient()) { request.Credentials = … Read more

How to improve the Performance of FtpWebRequest?

I have done some experimentation (uploading about 20 files on various sizes) on FtpWebRequest with the following factors KeepAlive = true/false ftpRequest.KeepAlive = isKeepAlive; Connnection Group Name = UserDefined or null ftpRequest.ConnectionGroupName = “MyGroupName”; Connection Limit = 2 (default) or 4 or 8 ftpRequest.ServicePoint.ConnectionLimit = ConnectionLimit; Mode = Synchronous or Async see this example My … Read more

Retrieving creation date of file (FTP)

This seems to work just fine http://msdn.microsoft.com/en-us/library/system.net.ftpwebresponse.lastmodified(v=VS.90).aspx FtpWebRequest request = (FtpWebRequest)WebRequest.Create (serverUri); request.Method = WebRequestMethods.Ftp.GetDateTimestamp; FtpWebResponse response = (FtpWebResponse)request.GetResponse (); Console.WriteLine (“{0} {1}”,serverUri,response.LastModified);