1

Closed

SftpClient.DownloadFile() && CoreFTP == Exception "No such file"

description

Hi again Oleg,
 
I am unable to use the Sftpclient.DownloadFile() function with a CoreFTP server. I am using SSH.NET release set 5836, unmodified, against CoreFTP Server 1.0 build 349.
 
The below program code generates the error further below. The same code, pointed to an OpenSSH server, works flawlessly. Any ideas?
 
////\\//// SOURCE CODE ////\\////
 
    static void Main(string[] args)
    {
        try
        {
 
            // Create a connection
            using (Renci.SshClient.SftpClient sftpClient = new SftpClient("127.0.0.1", 22, "username", "password"))
            {
 
                // Connect
                Console.WriteLine("Connecting...");
                sftpClient.Connect();
 
                using (MemoryStream localFileStream = new MemoryStream())
                {
                    sftpClient.DownloadFile("/test.txt", localFileStream);
                    localFileStream.Close();
                }

            }
 
        }
        catch (Exception ex)
        {
            Console.WriteLine(String.Format("EXCEPTION: {0}", ex.Message));
            Console.WriteLine();
            Console.WriteLine(ex.StackTrace);
            Console.WriteLine();
        }
}
 
////\\//// OUTPUT ////\\////
Connecting...
EXCEPTION: No such file
 
at Renci.SshClient.Sftp.SftpSession.WaitHandle(WaitHandle waitHandle, TimeSpan operationTimeout) in C:\Setup Disks\Programming\SSH.NET\sshnet-5836\Sftp\SftpSession.cs:line 296
at Renci.SshClient.Sftp.SftpCommand.EndExecute(SftpAsyncResult result) in C:\Setup Disks\Programming\SSH.NET\sshnet-5836\Sftp\SftpCommand.cs:line 53
at Renci.SshClient.Sftp.SftpCommand.Execute() in C:\Setup Disks\Programming\SSH.NET\sshnet-5836\Sftp\SftpCommand.cs:line 71
at Renci.SshClient.Sftp.SftpSession.GetAbsolutePath(String path) in C:\SetupDisks\Programming\SSH.NET\sshnet-5836\Sftp\SftpSession.cs:line 131
at Renci.SshClient.SftpClient.BeginDownloadFile(String path, Stream output, AsyncCallback asyncCallback, Object state) in C:\Setup Disks\Programming\SSH.NET\sshnet-5836\SftpClient.cs:line 309
at Renci.SshClient.SftpClient.DownloadFile(String path, Stream output) in C:\Setup Disks\Programming\SSH.NET\sshnet-5836\SftpClient.cs:line 293
at Ted.SFTP.Program.Main(String[] args) in C:\Setup Disks\Programming\SSH.NET\Test\Program.cs:line 43
Closed Jan 24, 2011 at 1:15 AM by olegkap
Fixed in 6176.

comments

olegkap wrote Jan 13, 2011 at 5:12 PM

Try to use latest codeset (5987) as I just fixed some DownloadFile related problem and let me know if you still have a problem.
I think it should be related cause I forgot to close the handle when download is competed and it I suspect it could be related to that.

Thanks,
Oleg

olegkap wrote Jan 19, 2011 at 12:55 PM

Can you let me know if latest codeset solved your problem?

Thanks,
Oleg

tedtaylor wrote Jan 19, 2011 at 4:46 PM

Hi Oleg,

Sorry, got busy with another project. I just downloaded codeset 5987 and the same issue still occurs.

Thanks,
Ted.


Connecting...
EXCEPTION: No such file

at Renci.SshClient.Sftp.SftpSession.WaitHandle(WaitHandle waitHandle, TimeSpan operationTimeout) in C:\Setup Disks\Programming\SSH.NET\sshnet-5987\Renci.SshClient\Sftp\SftpSession.cs:line 289
at Renci.SshClient.Sftp.SftpCommand.EndExecute(SftpAsyncResult result) in C:\Setup Disks\Programming\SSH.NET\sshnet-5987\Renci.SshClient\Sftp\SftpCommand.cs:line 53
at Renci.SshClient.Sftp.SftpCommand.Execute() in C:\Setup Disks\Programming\SSH.NET\sshnet-5987\Renci.SshClient\Sftp\SftpCommand.cs:line 71
at Renci.SshClient.Sftp.SftpSession.GetAbsolutePath(String path) in C:\Setup Disks\Programming\SSH.NET\sshnet-5987\Renci.SshClient\Sftp\SftpSession.cs:line 124
at Renci.SshClient.SftpClient.BeginDownloadFile(String path, Stream output, AsyncCallback asyncCallback, Object state) in C:\Setup Disks\Programming\SSH.NET\sshnet-5987\Renci.SshClient\SftpClient.cs:line 309
at Renci.SshClient.SftpClient.DownloadFile(String path, Stream output) in C:\Setup Disks\Programming\SSH.NET\sshnet-5987\Renci.SshClient\SftpClient.cs:line 293
at Ted.SFTP.Program.Main(String[] args) in C:\Setup Disks\Programming\SSH.NET\Test\Program.cs:line 43

olegkap wrote Jan 19, 2011 at 5:24 PM

ok, thanks,
I then will look at it tonight.

Thanks,
Oleg

olegkap wrote Jan 21, 2011 at 11:38 PM

I found the problem and it seems to be working now.

Can you please use latest 6176 codeset and let me know if it solved your problem.

Thanks,
Oleg

tedtaylor wrote Jan 23, 2011 at 6:59 PM

Hi Oleg!

Change set 6176 has fixed it. Many thanks!

Ted.