SiteCollection Storage Information

SharePoint has the Usage Analysis Time job, which updates the following information for the sites,

  • Storage,
  • Discussion Storage,
  • Bandwidth,
  • Hits,
  • Visits

The SPSite.Usage property gives us the information of site usage, bandwidth, visits.
Here I am adding the snippet for getting the Free Space available against Storage Quota and Space used by Site Collection,

using (SPSite site = new SPSite("http://localhost"))
SPSite.UsageInfo susg = site.Usage;
long spaceused = (((susg.Storage + 0x80000L) / 0x100000L));
if (site.Quota.StorageMaximumLevel == 0L)
Console.WriteLine("Storage Quota: Not applicable");
Console.WriteLine("Free Space Available: Unlimited");
long sitequota = (site.Quota.StorageMaximumLevel / 0x100000L);
long freespace = sitequota - spaceused;
Console.WriteLine("Storage Quota: " + sitequota.ToString());
Console.WriteLine("Free Space Available: " + freespace.ToString() + " MB");
Console.WriteLine("Storage Used: " + spaceused + " MB");

Leave a Reply

Your email address will not be published. Required fields are marked *


You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>