There is a code. In my opinion it is completely correct.
public static void MyFTP(string localFilePath, string ftpFileName) { using(FtpConnection ftp = new FtpConnection("87.237.43.11", "123", "123")) { ftp.Open(); /* Open the FTP connection */ ftp.Login(); /* Login using previously provided credentials */ string yearmonth = localFilePath.Substring(25, 6); MessageBox.Show(yearmonth); if (ftp.DirectoryExists("/archive/browse/RESURSDK/" + yearmonth)) /* check that a directory exists */ ftp.SetCurrentDirectory("/archive/browse/RESURSDK/" + yearmonth); /* change current directory */ else ftp.CreateDirectory("/archive/browse/RESURSDK/" + yearmonth); //do some processing try { ftp.SetCurrentDirectory("/archive/browse/RESURSDK/" + yearmonth); ftp.PutFile(localFilePath, ftpFileName); } catch (FtpException e) { Console.WriteLine(String.Format("FTP Error: {0} {1}", e.ErrorCode, e.Message)); } foreach(var dir in ftp.GetDirectories("/www/")) { Console.WriteLine(dir.Name); Console.WriteLine(dir.CreationTime); foreach(var file in dir.GetFiles()) { Console.WriteLine(file.Name); Console.WriteLine(file.LastAccessTime); } }
However the error takes off