I'm uploading a Word document from my desktop to SharePoint via the browser (Firefox, although I don't think that matters). If I then download the file that I just uploaded and compare it with the original file I uploaded it from on my desktop, they don't match. This comparison failure doesn't happen with a PDF file. Something on the SP side is changing the uploaded file.

I noticed this because I'm attempting to use the CSOM with C# to copy a file, but only after comparing and it doesn't match the original, in which case it should create a version with the today's date appended to the name. (I'm reading the file using OpenBinaryDirect and putting it into a byte array for comparison.) However, it keeps creating a new copy, even though the files should be identical.

Two questions:

  1. Is there a better way to compare the files (maybe a SharePoint CSOM method) besides comparing the byte arrays? I don't mind comparing the byte arrays, but when I know the files should be equal, and they don't match, something strange is up, and I'm guessing beyond my control.
  2. Any ideas on what's being changed in the files?

It's probably the metadata from the SharePoint columns in the document library.

SharePoint will embed the metadata from the columns in the library into Office documents. You can expose that data within the document itself using QuickParts.

Even if you don't want to use QuickParts, the data still gets embedded. I have had users ask me why a particular metadata field keeps defaulting to a certain value that it shouldn't be, and it is because the document they are uploading to the library was created from a copy of a document that they had downloaded from the library. Presumably the original document had most of the content they wanted and they only needed to edit a few things, so they downloaded the doc, copied it, renamed it, and made their edits. But even so, when they made the copy, the embedded metadata from the library was also copied, so when they went to upload the "new" document, the metadata fields got pre-populated with the data from the original document.

Now I can't say that that's definitively what's happening in your case, but it sounds like it might be, because as you noted, it happens with Word docs, but not PDFs.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.