Post a reply

Options
Add an Attachment

If you do not want to add an Attachment to your Post, please leave the Fields blank.

(maximum 10 MB; please compress large files; only common media, archive, text and programming file formats are allowed)

Options

Topic review

andybruner

Re: error using move file

Yes, I am trying to move files, not a folder. I think your reply helped me. Thanks.
martin

Re: error using move file

What are you actually trying to do? Your code does not seem to move a file. It moves a folder. The "Failure" might indicate that there already exists a folder (or a file) with that name in the target directory.
See https://winscp.net/eng/docs/sftp_codes#code_4

Didn't you actually want to move the files from the folder to the "processed" directory?
See https://stackoverflow.com/q/28436903/850848
andybruner

error using move file

I am getting this error when using move file. Can you help? Thanks.

General failure (server should provide error description).
Error code: 4
Error message from server: Failure

Here's my code:
using (Session session = new Session())
{
    // Connect
    string sftpFolder = "/parcs/download/" + mSysParam.Company;
    mLgr.LogInfo(sftpFolder);
    session.Open(sessionOptions);
 
    // download files
    TransferOptions transferOptions = new TransferOptions();
    transferOptions.TransferMode = TransferMode.Binary;
 
    TransferOperationResult transferResult;
    transferResult =
        session.GetFilesToDirectory(sftpFolder, mApplicationDataPath);
 
    localPPCounter++; //increase PP count so loop will stop
    //// Print results
    foreach (TransferEventArgs transfer in transferResult.Transfers)
    {
        mLgr.LogInfo("Download of file succeeded: " + transfer.FileName);
        mLgr.LogInfo("Destination:" + transfer.Destination);
    }
 
    session.MoveFile("/parcs/download/","/parcs/download/PNB/Processed");
}