SftpException No such file; File not found.

0 votes
asked Jul 1, 2011 by RealityEngineering (120 points)
edited Jul 19, 2011

I have been using the following block of code in an application for the past several months without any problem and now all of the sudden I'm getting a SftpException with the error message of "No such file; File not found.".

    private void SendDataFtp(string data, string fileName)
    {
        byte[] fileContents = Encoding.UTF8.GetBytes(data);
        MemoryStream ms = new MemoryStream(fileContents);

        using (Sftp ftp = new Sftp())
        {
            ftp.Connect("address", 22);
            ftp.Login("username", "password");
            ftp.PutFile(ms, fileName);
        }
    }

I also updated my installation or at least I think I did. I'm using the following assemblies:

Rebex.Net.ProxySocket (version 2.0.4086.0) Rebex.Net.Sftp (version 2.0.4086.0) Rebex.Net.Ssh (version 2.0.4086.0)

What's the problem? Not sure why it's complaining that it can't find a file when I'm not trying to get a file but rather upload a file.

Scott

Applies to: Rebex SFTP

1 Answer

0 votes
answered Jul 4, 2011 by Lukas Pokorny (103,050 points)
edited Jul 19, 2011

This exception represents an error that was reported by the SFTP server and it's indeed a bit strange for the PutFile method. However, it might be related to a path, not the actual file name. To make it possible to tell what is going on, please create a log of communication using Sftp object's LogWriter property and either add it to your question or mail it to support@rebex.net Thanks!

...