After downloading file from SFTP, we will get null value in the file extension parameter.

Jan 11, 2013 at 6:41 AM

We are using latest version of SSH.Net library. We are getting null value in the file extension once file is downloaded from the server. Please check below BOLD word "myFile". When we check the properties of this paramter we are gettting null value in the extension parameter.

Please check below code.

IEnumerable<Renci.SshNet.Sftp.SftpFile> myfileList = client3.ListDirectory("/.");

            foreach (Renci.SshNet.Sftp.SftpFile myFile in myfileList)
            {
                if (myFile.Name == "ABC.csv")
                {
                    var mem = File.Create("D:\\temp\\ABC.csv");
                    var asynch = client3.BeginDownloadFile("/ABC.csv", mem, null, null);
                    var sftpAsynch = asynch as Renci.SshNet.Sftp.SftpDownloadAsyncResult;
                   
                    client3.EndDownloadFile(asynch);

                }
            }

Coordinator
Jan 11, 2013 at 3:47 PM

Hi,

 

If you mean that Extensions is null, it means that SFTP server probably did not return any additional information.

However I could not find any server to test this feature on and only implemented it as it specified by protocol so may be I do have an error somewhere but to test it I would need to have access to SFTP server which provide Extensions information.

 

Hope it helps,

 

Thanks,

Oleg