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.


Following code solved our issue

SPSite spSite = new

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.

1 Comment »

  1. Anonymous said

    last accessed and last modified are different .The code is for last modified .

RSS feed for comments on this post · TrackBack URI

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: