I am using SystemUpdate(false) in my code block and was not able to retain the modified values for a document library (both folders and files) when I am trying to rename the folder or file. Please have a look at the code:

Web.AllowUnsafeUpdates = true;

spItem = Web.Lists["MydocumentLibrary"].GetItemById(itemID);
//string tempFName = string.Empty;
tempFName = spItem.DisplayName;
//spItem["Name"] = ReplaceIllegalCharacters(values["DocLibItemName"].ToString().Trim());
if (spItem.FileSystemObjectType == SPFileSystemObjectType.File)
    //When we try to rename file name having period(dot), part of the text after dot terminates.
    //To overcome this issue we are appending some text "._" at the end of the filename [CQ:profs00032447]
    spItem["Name"] = ReplaceIllegalCharacters(values["DocLibItemName"].ToString().Trim() + "._");
    spItem["Name"] = ReplaceIllegalCharacters(values["DocLibItemName"].ToString().Trim());

// spItem.Update();
// spItem["Modified"] = spItem.File.TimeLastModified;


Web.AllowUnsafeUpdates = false;

Am I missing something or do I need to CheckOut files and then use SystemUpdate and later CheckIn the files?

  • For your information , this is not an eventhandler I am populating mine data in Gridview and trying to edit(Rename File / Folder) it from there..
    – Ash
    Apr 21, 2011 at 11:07
  • 1
    Have a look at the SO question How can “Modified By” be changed when using RunWithElevatedPrivileges?. Might be useful. Apr 21, 2011 at 13:47
  • I edited your question to say "modified value" instead of "field" as I think that's what you mean - the modified values are changing when you want them to stay the same? If that's wrong, please edit the question to clarify. Thanks!
    – Alex Angas
    May 16, 2011 at 7:01

1 Answer 1


There are two separate values which you might be trying to modify; the name of the file itself; or the name of the file as stored by the list item.

If it is the latter - this is stored as the Title field - spItem["Title"]; if it's the former then you will need to change it on the spItem.File object. I think you may be changing a different value to what you expect to be changing, by changing the "Name" value.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.