SftpException in Rename method

0 votes
asked May 23, 2012 by BPK (160 points)
edited Jul 4, 2012

Hi,

I am getting similar exception, while trying to rename the file on SFTP server. My current code performs an upload as tmp file and then rename it as actual file once the upload is complete.

Currently I am checking rename if it fails not to delete the file locally.But Because of this we are having data duplication. So essntially Rename method is renaming but failing later! currently using as below if(!Rename(filefrom,fileto) { Delete local file } else { Renaming failed dont delete the file } Error messages apppearing during rename are as below:

**Renaming of file failed exception :System.InvalidOperationException: Not authenticated to the server.

Or

Renaming of file failed exception :Rebex.Net.SftpException: Cannot perform requested operation in current session state. ---> Rebex.Net.SshException: Cannot perform requested operation in current session state. ---> Rebex.Net.SshException: Cannot perform requested operation in current session state.**

Are there any known problems for Rename method? Regards, Bindu

Applies to: Rebex SFTP
commented May 23, 2012 by Lukas Pokorny (121,750 points)
edited May 23, 2012

This looks like another error occurred before you called the Rename method. That error caused the session to become disconnected and unusable. In this state, it's no longer possible to call SFTP methods (such as Rename), but it looks like it's not detected properly in some cases.

In any case, the problem is almost certainly not related to the Rename method, but another operation attempted before that which threw an exception that was ignored.

Please try creating a communication log using Sftp object's LogWriter property and add it to your post or mail it to support@rebex.net for analysis.

commented May 23, 2012 by BPK (160 points)
edited May 23, 2012

Hi Lukas,

Thanks for coming back quickly. However the problem is SFTP server has received this file and already renamed it correctly.

So,We have duplication of data on server side.

Regards, Bindu

1 Answer

0 votes
answered May 23, 2012 by Lukas Pokorny (121,750 points)

We really need to see the communication log. Without it, we can't tell what's going on. Please create one, we should be able to help then!

...