I want to modify a lot of files in SharePoint programmatically, but it's important to not create a new version. When versioning is turned off for a list, this is easy to do using
file.CheckOunt();
file.SaveBinary(/*data*/);
file.CheckIn(file.CheckInComment, SPCheckinType.OverwriteCheckIn);
But when versioning is turned on, and the current version is published, this does not work and gives the following error message instead:
You cannot checkin and overwrite a published file.
Is there a way to override a file without changing version, that works in every situation?
There reason why I need this is the following: My program makes the files smaller while keeping their format and their visual content. It uses compression strategies that are built into the format to achieve the smallest possible size. So, the goal is to save space. But when I create a new version with the smaller file instead of the existing one, this would not make any sense at all.