Archive for March, 2010

SharePoint 2007: Last Modified Date of Lists / Document Libraries

Scenario: We need to find the last access / modified date of all document libraries in a site collection.

Resolution:

Following code solved our issue

SPSite spSite = new
SPSite(“SiteCollectionURL”);

SPWeb spWeb = spSite.OpenWeb();

SPListCollection listColl = spWeb.Lists;

DateTime lastModifiedDate;

foreach (SPList list in listColl)

{     

if (list.BaseType == SPBaseType.DocumentLibrary)

{     

lastModifiedDate = list.LastItemModifiedDate;

Console.WriteLine(“Document Library Title:” + list.Title + “\nLast Modified Date:” + lastModifiedDate + “\n\n”);

}

}

P.S. Please change BaseType as per your requirement for Lists etc or remove this check all together.

Advertisements

Comments (1)