I have a job that runs every five minutes and puts some information to the footer of the Word documents. Versioning is enabled on the list so whenever the job runs, a new version is created for every document.

Is there a way to modify the documents without creating new versions every time?

Currently, I am reading the file contents with SPFile.OpenBinary(), modifying the stream, then putting the file back with file.ParentFolder.Files.Add(fileName, stream).

Any help is greatly appreciated.

3 Answers 3


You can call SystemUpdate(false) method to update the item without incrementing the version number. More information here: http://msdn.microsoft.com/en-us/library/microsoft.sharepoint.splistitem.systemupdate.aspx

  • But I am not updating the item. I am not calling item.Update() anywhere. Just pulling the binary stream then putting it back as I wrote in my question. Dec 4, 2011 at 14:16
  • When you call add method, a new file is upload and if file name is same a new version is created. I am not sure you can avoid a new version in that case. Dec 4, 2011 at 14:32
  • So, is there any way for modifying the contents of the file other that requires adding file to parent file collection? Dec 5, 2011 at 7:39
  • The File itself exists as special kind of attachment in the ListItem. If you modify the file you must call Update(). If you don't want a new version created, you must call SystemUpdate(false). Test this out and see if it still creates a new version.
    – James Love
    Dec 5, 2011 at 13:46
  • I am not working on the list item. I get the item, open it's attachment by calling item.File.OpenBinaryStream(). So item itself is not updated anywhere. When I am finished working on the file, I put it back to file collection of parent folder. So I am not calling listItem.Update() or listItem.SystemUpdate(). Those calls are not needed in my case. But a new version is automatically created when I put the file in parent folder. Dec 6, 2011 at 12:16

All of your posts helped me build a solution.

We are using the Client Object Model (COM) and cannot refer to SharePoint.dll which has the SPList object. In our given scope of COM, I could accomplish it by doing this in the C# code.

  1. Load the File and check out

            file.CheckOut(); // Check out the File
  2. Update our file properties as follows:

            file.ListItemAllFields["Owner"] = "Owner Name";
            file.ListItemAllFields["Field"] = "Value";
  3. Finally Update the List Item and Check in the file as shown below

            file.ListItemAllFields.Update(); // Update the Properties
            // Checkin the file with Overwrite to maintain the version
            file.CheckIn(string.Empty, CheckinType.OverwriteCheckIn); 

Hope this helps some one.

  • 1
    Ravi, is this answer related to the question above? I am not sure if you answered the correct question.
    – Kit Menke
    Jun 19, 2012 at 22:03

If you don't want to keep the version, it seems you no longer need the unmodified file. You can delete(SPFileCollection.Delete) the file and add the modified one after that.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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