3

We are migrating a large directory structure of documentation into SharePoint 2007. In our tests, SharePoint obviously sets the created and modified date to the upload time. Is there anyway to change that to the information from the file?

We are already setting various other metadata in our upload script, but it appears that we can't modify those values.

Doug Luxem
  • 9,592
  • 7
  • 49
  • 80

2 Answers2

3

Here are some more details on using the API to update the created and modified dates on items in SharePoint:

SPSite site = new SPSite("http://sharepointsite/subsite");
SPWeb web = site.OpenWeb();
SPList list = web.Lists["My List"];
web.AllowUnsafeUpdates = true;
foreach (SPListItem item in list.Items)
{
   item["Modified"] = "Set the date";
   item["Created"] = "Set the date";
   item.UpdateOverwriteVersion();
}
Doug Luxem
  • 9,592
  • 7
  • 49
  • 80
  • Unfortunately this will only modify the dates of the SPListItem, but the containing thread will still have today's date/time. – niaher Mar 20 '12 at 11:33
1

You can do it through the API, the Created property on SPListItem is writable.

Brandon
  • 2,807
  • 1
  • 22
  • 28