Skip to content

$exception {"Failure"} Renci.SshNet.Common.SshException I get exception on downloading the files #945

Open
@mukesh-rep

Description

@mukesh-rep

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, Action1 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

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions