Welcome to MSDN Blogs Sign in | Join | Help

Syndication

Tags

    No tags have been created or used yet.

News

ALL POSTING ARE PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND
How to Retain/Preserve "Modified By" while checking in a file

SPSite mySite = new SPSite("<SiteURL>");

SPWeb myWeb = mySite.OpenWeb();

SPFolder myList = myWeb.Folders["<DocLibName>"];

SPFile myFile = myList.Files[0];

SPUser myUser = myWeb.Users["<User_Name>"];

CheckInFileByUser(myFile, "Checkin Comments", SPCheckinType.MajorCheckIn, myUser);

public static void CheckInFileByUser(SPFile file, string checkinComment,SPCheckinType checkinType,SPUser modifiedByUser)

{

MethodInfo mi = typeof(SPFile).GetMethod("CheckIn",BindingFlags.Instance | BindingFlags.NonPublic, null, new Type[] { typeof(string), typeof(SPCheckinType), typeof(bool), typeof(SPUser) }, null);

try

{

mi.Invoke( file, new object[] { checkinComment, checkinType, false, modifiedByUser });

 

}

 

catch (Exception ex)

{

MessageBox.Show(ex.StackTrace);

}

}

Before calling this code you will need to Check out the file, otherwise you will get an error.
 

 

Published Wednesday, April 15, 2009 4:21 AM by Pavan

Comments

# How to Retain/Preserve &#8220;Modified By&#8221; while checking in a file | Microsoft Share Point @ Wednesday, April 15, 2009 12:19 AM

PingBack from http://microsoft-sharepoint.simplynetdev.com/how-to-retainpreserve-modified-by-while-checking-in-a-file/

How to Retain/Preserve &#8220;Modified By&#8221; while checking in a file | Microsoft Share Point

Anonymous comments are disabled
Page view tracker