ComponentPro UltimateSftp

      Download data to a stream

      Language Filter: AllSend comments on this topic to ComponentPro

      The Scp class allows you to download file from the remote server to a stream easily by using the DownloadFile method. See the following example for more details:

      using System.IO;
      using ComponentPro.Net;
      
      ...
      
      // Create a new class instance.
      Scp client = new Scp();
      
      // Connect to the SCP server.
      client.Connect("localhost");
      
      // Authenticate.
      client.Authenticate("test", "test");
      
      // ... 
       
      // Create new file
      FileStream fo = new FileStream("c:\\file.dat", FileMode.Create);
      
      // Download remote file to the stream.
      client.DownloadFile("/file.dat", fo);
      
      fo.Close(); 
      
      // ... 
       
      // Disconnect.
      client.Disconnect();