Beispiel #1
0
 private void DownFiles(FtpConnection connection)
 {
     try
     {
         connection.ChDir("PDA");
         string[] files = connection.GetFiles();
         if (null != files && files.Length > 0)
         {
             var app_dir = Path.GetDirectoryName(Assembly.GetExecutingAssembly().GetName().CodeBase);
             for (int i = 0; i < files.Length; i++)
             {
                 connection.DownloadFile(files[i], app_dir + "\\" + files[i]);
             }
             Console.WriteLine("download complete");
         }
         else
         {
             Console.WriteLine("the directory has any file");
         }
     }
     catch (Exception ex)
     {
         Console.WriteLine(ex.Message);
     }
     finally
     {
         connection.Close();
     }
 }