OverwriteMode.Append using PutFile on an SFTP server, doesn't appear to work
Hi, I'm using the WinSCP
I extracted some code out of our build just to show how the
Thanks so much!
PutFile
programmatically in C# to stream byte data to our SFTP server to create files and using the overwrite mode it works great. However, after the file is created and exists, all subsequent PutFile
calls w/ the TransferOptions.Overwrite = OverwriteMode.Append
still just overwrite the file. I thought WinSCP using an SFTP server was suppose to support appending data to existing files if using the OverwriteMode.Append
mode, is that correct? Can someone help me resolve this problem?
I extracted some code out of our build just to show how the
PutFile
is being called without the sessionOptions
, maybe this will help to shed some light on why the append doesn't work.
Thanks so much!
sessionOptions = new SessionOptions{...} TransferOptions transferOptions = new TransferOptions(); transferOptions.TransferMode = TransferMode.Binary; transferOptions.OverwriteMode = OverwriteMode.Append; String data = "Hello World\n"; byte[] byteArray = Encoding.ASCII.GetBytes(data); using (MemoryStream stream = new MemoryStream(byteArray)) { using (Session session = new Session()) { session.Open(sessionOptions); session.PutFile(stream, "/sftpuser/test/test.txt", transferOptions); } }