sftprebex

Problems with rebex sftp file deletion


I'm get a SftpException: No such file; File not found. when using Rebex sftp's Sftp.DeleteFile(string filename) which is especially odd because I'm first checking that the file exists.

Here's the relevant sample code:

foreach (var file in fileList)
{
    if(ftp.Connection.FileExists(file.Name))
    {
        try
        {
            ftp.Connection.DeleteFile(file.Name);
        }
        catch (SftpException ex)
        {
            Log.Error("Deletion failed.", ex);
        }
    } 
    else
    {
         Log.Debug(string.Format("'{0}' not found.", file.Name));
    }
}

Rebex's online docs can be found here for those not familiar with the library.

Any ideas as to what's going on here?


Solution

  • David also asked this question on our support forum at http://forum.rebex.net/questions/1635/sftpexception-no-such-file-file-not-found

    I'm recording the solution here too, because it can be handy in similar situations.

    Unfortunately the SFTP server error message was not very helpful in this case. One could ask if something like "access denied" would not be more appropriate.