Saturday, 10 September 2011

Check in\Check Out document using sharepoint object model


A small code tip how to get Check in or Check Out documents using sharepoint object model.

\\Get the document Lib
SPDocumentLibrary Lib = (SPDocumentLibrary)web.Lists["Share Documents"];

foreach (SPFile file in Lib.Files)
{
if (file.CheckOutType == SPFile.SPCheckOutType.None)
{
//Check out all the files
file.CheckOut();
}
}

// Now Check in the documents with a comment.
foreach (SPFile file in Lib.RootFolder.Files)
{
if (file.CheckOutType != SPFile.SPCheckOutType.None)
{
file.CheckIn("Checked In using Object Model");
}
}}}

Ads by Google

No comments:

Post a Comment