Unable to overwrite file using WinSCP dll

Advertisement

T.Hylander
Joined:
Posts:
4

Unable to overwrite file using WinSCP dll

Hi,
Trying to upload and overwrite a file on our server over Webdav-protocol, but just getting a "500 internal server error"-message. Doing the same on the WinSCP-client works like it should.
Uploading a new file works like a charm as well. Credentials on server is double-checked.
Generated script from client, and just used the example from website, with the addition by adding transferOptions.OverwriteMode = OverwriteMode.Overwrite.
SessionOptions sessionOptions = new SessionOptions
{
    Protocol = Protocol.Webdav,
    HostName = "www.domain.se",
    UserName = "User",
    Password = "Password",
    WebdavSecure = true,
    TlsHostCertificateFingerprint = "00:00:00:00:00:00:00:00:00:00:00",
 
};
using (Session session = new Session())
{
    // Connect
    session.Open(sessionOptions);
 
    // Upload files
    TransferOptions transferOptions = new TransferOptions();
    transferOptions.TransferMode = TransferMode.Binary;
    transferOptions.OverwriteMode = OverwriteMode.Overwrite;
 
    TransferOperationResult transferResult;
    transferResult =
        session.PutFiles(@"C:\temp\test.json", "/webdav/files/test/", false, transferOptions);
    // Throw on any error
    transferResult.Check();
 
    // Print results
    foreach (TransferEventArgs transfer in transferResult.Transfers)
    {
        MessageBox.Show("Upload of " + transfer.FileName + " succeded");
    }
}
The complete error-message:
WinSCP.SessionRemoteException: Error transferring file 'c:\temp\test.json'
500 Internal Server Error
at WinSCP.OperationResultBaseCheck()
at ProgramFormProgram.button2_Click(Object sender, EventArgs e) in c:\temp\Program\Form1.cs::row 220
I also tried using Session.PutFileToDirectory but that didn't change anything.

Does anyone have some hints on what I should look for?
Thanks!

Reply with quote

Advertisement

martin
Site Admin
martin avatar
Joined:
Posts:
36,052
Location:
Prague, Czechia

Re: Unable to overwrite file using WinSCP dll

Please post complete session log files both for the successful overwrite in GUI and the failed overwrite in code.

Reply with quote

T.Hylander
Joined:
Posts:
4

Hi,
Where do I find the log from the code, besides the above fetched by the try..catch-statement?
Client log attached as private file.

Edit: Also tried session.RemoveMile([file]) but that throw the same error.
  • WinSCP_uploaderrorlog.log (34.41 KB, Private file)

Reply with quote

Advertisement

Advertisement

You can post new topics in this forum