Welcome to MSDN Blogs Sign in | Join | Help

How BIG is your SharePoint

Size of Site collection:

string siteCollectionURL = “http://localhost:80/sites/TestSite”;
SPSiteAdministration oSPSiteAdministration = new SPSiteAdministration(siteCollectionURL);
float scDiskUsage = oSPSiteAdministration.DiskUsed;
float sizeOfSiteCollection = (scDiskUsage / (1024 * 1024));  // In MB
 

 

Total size of sub-sites in Site collection :

string siteCollectionURL = “http://localhost:80/sites/TestSite”;
SPSite oSPSite = new SPSite(siteCollectionURL);
SPWeb oSPWeb = oSPSite.RootWeb;
float totalSubSitesUsage = GetWebSize(oSPWeb);
float GetWebSize(SPWeb web)
{
  float total = 0;
  foreach (SPFolder folder in web.Folders)
  {
    total += GetFolderSize(folder);
  }
  foreach (SPWeb subweb in web.Webs)
  {
    total += GetWebSize(subweb);
    subweb.Dispose();
  }
  return (total/(1024*1024));
}
 
float GetFolderSize(SPFolder folder)
{
 float folderSize = 0;
 foreach (SPFile file in folder.Files)
 {
   folderSize += file.Length;
 }
 foreach (SPFolder subfolder in folder.SubFolders)
 {
   folderSize += GetFolderSize(subfolder);
 }
 return folderSize;
}

Published Wednesday, June 03, 2009 1:57 PM by chandrasekarn

Comment Notification

If you would like to receive an email when updates are made to this post, please register here

Subscribe to this post's comments using RSS

Comments

Wednesday, June 03, 2009 9:14 AM by How BIG is your SharePoint | Microsoft Share Point

# How BIG is your SharePoint | Microsoft Share Point

Leave a Comment

(required) 
required 
(required) 

  
Enter Code Here: Required
 
Page view tracker