The following article may help with what I'm asking:

http://msdn.microsoft.com/en-us/library/ee559302%28office.14%29.aspx

I'm doing research on the behavior of the MOSS2010 Document ID functionality, and I am having difficulties moving a SPFile object from one document library to the other.

If I put a file "Document_A.doc" into document library "DocLib1", and move the SPFile (using the "MoveTo" method on SPFile) to document library "DocLib2", the document ID value is preserved, but it appears that SharePoint is no longer able to find the file using the document ID, either via the SharePoint Document ID link in a list view, or via the Microsoft.Office.DocumentManagement.DocIdLookup API methods.

Now, if I use "CopyTo" to put the document into "DocLib2", a new Document ID is generated for the copy. This is NOT useful for my purpose, as I want to use a DB-stored DocumentID to reliably find the document again, and if it changes without me knowing about it, my ID will be invalid.

That said, the link above refers to a "Persist ID" field. From what I can tell, if the "Persist ID" field is set to true before copying the file, the document ID is NOT changed for the copy, but stays the same. Which would be perfect for my purposes...

... except it doesn't seem to work. A new Document ID is getting generated for the copy.

Here is the code where I take an SPFile object, get the Persist ID field, set the property to true and invoke CopyTo. I don't think I've missed anything:

private void MoveFileTo(string destURL, SPFile fileToMove) { SPListItem listItem = fileToMove.ListItemAllFields; SPFieldCollection fields = listItem.Fields;

string persistIDFieldName = fields["Persist ID"].InternalName;

fileToMove.Properties[persistIDFieldName] = true; bool persistID = Convert.ToBoolean(fileToMove.Properties[persistIDFieldName]);

fileToMove.CopyTo(destURL); fileToMove.Delete(); }

Anyone else doing work with Document ID functionality? What has your experiences been?

link|improve this question
feedback

Know someone who can answer? Share a link to this question via email, Google+, Twitter, or Facebook.

Your Answer

 
or
required, but never shown

Browse other questions tagged or ask your own question.