Tuesday, December 18, 2012

Code snippet to update Sharepoint 2010 Modified By

When uploading files, the date created and date last modified is not taken from the file system. Instead, it is generated by Sharepoint.
You can build your own API to upload a file to Sharepoint and update the fields programmatically.

SPFieldUserValue author = new SPFieldUserValue(web, spUser.ID, spUser.LoginName);
listItem[SPBuiltInFieldId.Created] = dtCreated;
listItem[SPBuiltInFieldId.Modified] = dtModified;
listItem[SPBuiltInFieldId.Author] = author;
listItem[SPBuiltInFieldId.Editor] = author;
listItem.Update();
Related Posts Plugin for WordPress, Blogger...