Reputation: 1
Can I update these fields dynamically?
SPFile file = ds.Files.Add(ds.Url + @"\" + record.Name, data, true);
file.Item["Created_x0020_By"] = "test";
file.Item[SPBuiltInFieldId.Author] = "testauthor";
file.Item[SPBuiltInFieldId.Editor] = "test editor";
file.Item.Update();
Upvotes: 0
Views: 3428
Reputation: 1024
You can't update the Author and Editor using String...
You need to pass as SPUser.
For example u want to save current user use
SPContext.Current.Web.CurrentUser
If you want to save as other user please use
SPUser user = SPContext.Current.Web.EnsureUser("domain\\username");
file.item["Author"] = user
Upvotes: 1