Open mcaupybugs opened 4 months ago
AppendAllText
is not aware about file types. It is just appending the bytes of the input to the bytes of the file. I imagine you would get the same result with System.IO.File.AppendAllText
.
If you need to manipulate .docx files, I recommend you play with Open XML SDK https://learn.microsoft.com/en-us/office/open-xml/open-xml-sdk
@mcaupybugs can you prepare a failing integration test for the .docx
file?
Docx is a archived zip file with xml files inside. Would this not be expected behavior
I have two scenarios to consider.
appendAllText
functionality of the SftpClient to append two .docx files. The steps I perform in sequence are -FileMode.Append
mode and provide the file access asFileAccess.Write
, which returns a SftpFileStream.using (var memoryStream = new MemoryStream(byteArrContent))
and useawait memoryStream.CopyToAsync(sftpFileStream)
to copy the bytes of the second docx to the first one. It also ends up corrupting the docx file.I wanted to know if append functionality is not supported for such file types, or If I am missing something.