Error using move file

Advertisement

andybruner
Joined:
Posts:
7

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"); 
}

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
41,506
Location:
Prague, Czechia

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 Moving (not copying) remote files after download with WinSCP .NET assembly

Reply with quote

Advertisement

You can post new topics in this forum