ComponentPro UltimateSftp

      Upload and download a file

      Language Filter: AllSend comments on this topic to ComponentPro

      Using the UploadFile method to store and DownloadFile method to download a single file. Both methods have overloads that allow you to upload and download a file from and to memory instead of disk. See the "Upload data from a stream" and "Downloading data to a stream" for more information.

      The example below shows you how to use the UploadFile and DownloadFile methods to upload and download a single file:

      using System;
      using ComponentPro.IO;
      using ComponentPro.Net;
      // Create a new class instance.
      Scp client = new Scp();
          // Connect to the SCP server. 
          // Authenticate. 
          client.Authenticate("test", "test");
          // ... 
          // Upload file "c:\". 
          client.UploadFile("c:\\", "");
          // Download the "" file. 
          client.DownloadFile("", "c:\\");
          // ... 
          // Disconnect. 
      catch (ScpException exc)
          Console.WriteLine("An error occurred: Code: {0}, Message: {1}", exc.Status, exc.Message);
          if (client.State != RemoteFileSystemState.Disconnected)