Ejemplo n.º 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();
     }
 }
Ejemplo n.º 2
0
    static void Download(string [] Input)
    {
        if (!Client.IsConnected)
        {
            Console.WriteLine("Please connect to a server first.");
            return;
        }
        string SaveFile;

        if (Input == null)
        {
            Console.WriteLine("Invalid parameters");
            return;
        }
        if (Input.Length > 1)
        {
            Input[0] = string.Join(" ", Input);
        }
        Console.Write("Save file to: ");
        SaveFile = Console.ReadLine();
        Client.DownloadFile(Input[0], SaveFile);
    }