In this post we will see how we can check-in items in SharePoint document library using SharePoint 2010 object model.
One of the major improvement towards content management in SharePoint 2010 is the ability to check in and check out multiple documents at one time using browser. Here we will see how we can do check in using SharePoint 2010 object model.
Here first we will check wether the item has been already check out or not. If it is in Checked out mode then we will check in the item. We will use the Shared Documents folder.
Below is the full code:
using (SPSite siteCollection = new SPSite("http://Site URL"))
SPWeb site = siteCollection.RootWeb;
SPList list = site.Lists["Shared Documents"];
foreach (SPListItem item in list.Items)
if (item.Level == SPFileLevel.Checkout)
item.File.CheckIn("Checked In", SPCheckinType.MajorCheckIn);