Anyone who has experience with programmaticly updating the SPFileVersion.Properties Hashtable?
I have a special situation where I would like to modify this Hashtable. Most of you will say: "Why on earth would you ever want to change this programmaticly". Believe me, we have our reasons to do so. If necessary I would love to explain this. But atm this has nothing to do with the problem.
I am using this code, but it does not change anything in the "Version History" in the UI.
I've tried several things, I'll just show some easy lines of code which do not work at all:
using (SPSite oSite = new SPSite("[MY URL]"))
{
using (SPWeb oWeb = oSite.OpenWeb())
{
SPList oList = oWeb.Lists["Documents 2"];
SPListItem oItem = oList.Items.GetItemById(23);
foreach (SPFileVersion version in oItem.File.Versions)
{
if(!version.IsCurrentVersion)
{
version.Properties["vti_title"] = "TESTTITLE";
}
}
oItem.Update();
}
}
So the above code is not doing anything, I've put a "watch" on version.Properties["vti_title"] and this watch does change to the new value. But it does not get saved to SharePoint ?
I've used Update, SystemUpdate, UpdateOverwriteVersion, SPFile.Update
Thanks
Edit:
Why I want to do this:
The fact is I have created a copy/move custom workflow activity which copies or moves files in the entire farm. This also works with RMS protected libraries. It's a "hack" to get documents out of RMS. This was required by the customer for a "read/edit area concept".
Copying files out of libraries with RMS enabled can cause alot of issues because it is simply not supported. But I managed to get around all these issues, only one problem stays: After MOVING (so move, not copy) a file in the farm, the version histories metadata is lost. (only the current versions metadata is shown) (original document: http://i40.tinypic.com/jaf3fb.png , document after move: http://i40.tinypic.com/e5qkx1.png).
So to fix this, I would like to modify each version serperatly and set the correct version metadata as was visible before the move. If you use the default SPFile.MoveTo this version metadata is lost aswell. The only way to get what I want is to move the file using "Manage content and structure"... (this uses SPExport/SPImport, which I am not allowed to use + SPExport/SPImport does not work with RMS enabled libraries)