Quantcast
Channel: sshnet Discussions Rss Feed
Viewing all articles
Browse latest Browse all 1729

New Post: sftp download file

$
0
0
using (var client = new SftpClient("<address>", <port>, <uid>, "<pw>"))
{
client.Connect();
List<Renci.SshNet.Sftp.SftpFile> Files = client.ListDirectory("<ftp file directory>").ToList();

foreach (Renci.SshNet.Sftp.SftpFile CurrentFile in Files)
{
  /// Download into file stream
       FileStream fs = new FileStream(Folder + CurrentFile.Name, FileMode.Create);
       client.DownloadFile(CurrentFile.Name, fs);

       /// Close file stream
       fs.Close();
}

client.Disconnect();
}


Hope this helps.

Viewing all articles
Browse latest Browse all 1729

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>