Online Training On SharePoint
                      

Thursday 19 November 2009

Finding the size of Document Library using SharePoint Object Model

I was working on a SharePoint site where lot of document libraries were there. We had a task to get the size of all these document library. We can do this using the following Object Model Code:
using (SPSite testsite = new SPSite("http://localhost")) 
{ 
       DataTable datatbl; 
       datatbl = testsite.StorageManagementInformation( 
       SPSite.StorageManagementInformationType.DocumentLibrary,  
       SPSite.StorageManagementSortOrder.Decreasing, 
       SPSite.StorageManagementSortedOn.Size, 100); 
       foreach (DataRow drow in datatbl.Rows) 
       { 
          foreach (DataColumn column in datatbl.Columns) 
          MessageBox.Show("Doc Lib Name :" + drow["Title"].ToString() + "  Size (bytes): " + drow["Size"].ToString()); 
       } 
} 

No comments:

Related Posts with Thumbnails