//get the created and modified details of the list item. private static void ShowCreatedByAndModifiedByDetailsOftheListItem(SPList list) { string createdBy = string .Empty; string modifiedBy = string .Empty; int index; foreach (SPListItem item in list.Items) { createdBy = item[ "Created By" ].ToString(); if (createdBy != null ) { index = createdBy.IndexOf( '#' ); if (index > 0) { Console.WriteLine(item.Title + " created by " + createdBy.Substring(index + 1, createdBy.Length - index - 1)); } else { Console.WriteLine( "index is less than 1,there is an error in the created by name" ); } } modifiedBy = item[ "modified By" ].ToString(); if (modifiedBy != null ) { index = modifiedBy.IndexOf( '#' ); if (index > 0) { Console.WriteLine(item.Title + " modified by " + modifiedBy.Substring(index + 1, modifiedBy.Length - index - 1)); } else { Console.WriteLine( "index is less than 1,there is an error in the modified by name" ); } } } } |
As the above code we need to eliminate the key from the name. Thus we will get the names of the particulars. We will the string of the user name with the key value in the line createdBy = item["Created By"].ToString();. Print the string after the # value. Apply same thing for modified By details also.
Hope this will help you.
Comments