I am copying list items across lists using below code. Works for the most part but the author, created, and modified fields are not getting carried over. How can I preserve them? I tried systemupdate method but that did not help.
//copy sourceItem to destinationList
SPList destinationList = sourceItem.Web.Lists[destinationListName];
SPListItem targetItem = destinationList.Items.Add();
foreach (SPField f in sourceItem.Fields)
{
if (!f.ReadOnlyField && f.InternalName != "Attachments")
{
targetItem[f.InternalName] = sourceItem[f.InternalName];
}
}Any pointers?
Thanks!