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

T.Hylander

Works like a charm now, thanks!
martin

Try setting SessionOptions.RootPath to "/webdav/files/Integrationer/Driftsstörningar".
T.Hylander

Code log attached.
T.Hylander

Client log attached as private file.

Also tried session.RemoveMile([file]) but that throw the same error.
T.Hylander

Unable to overwrite file using WinSCP dll with WebDAV

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 GUI 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!