Description
Hi team
I'm using the below code for downloading files from the SFTP server.
` DataLakeFileSystemClient fileSystemClient = new DataLakeFileSystemClient(connectionString, "container");
DataLakeDirectoryClient processDirectory = fileSystemClient.GetDirectoryClient("testProcessDir");
using (var sftp = new SftpClient(host, username, password))
{
sftp.Connect();
var files = sftp.ListDirectory(remoteDirectory);
foreach (var file in files)
{
string remoteFileName = file.Name;
if (!file.Name.StartsWith(".") && (DateTime.UtcNow - file.LastWriteTimeUtc).TotalHours < 1)
{
DataLakeFileClient newfile = processDirectory.CreateFile(file.Name);
using (Stream stream = newfile.OpenWrite(overwrite: true))
{
sftp.DownloadFile(remoteDirectory + remoteFileName, stream);
}
}
}`
After downloading 1 or few files it gives execption as $exception {"Failure"} Renci.SshNet.Common.SshException
at Renci.SshNet.Sftp.SftpFileReader.Read()
at Renci.SshNet.SftpClient.InternalDownloadFile(String path, Stream output, SftpDownloadAsyncResult asyncResult, Action1 downloadCallback) at Renci.SshNet.SftpClient.DownloadFile(String path, Stream output, Action
1 downloadCallback)
at _111111111111.Program.DownloadAll() in D:\workspace\ExampleProjects\111111111111\111111111111\Program.cs:line 75
at _111111111111.Program.Main(String[] args) in D:\workspace\ExampleProjects\111111111111\111111111111\Program.cs:line 15
Please suggest something with which I could download all the files.
Thanks,
Mukesh