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");

Shantha Kumar
Shantha Kumar
Articles: 270

One comment

  1. When using SPSite.Usage.Hits and SPSite.Usage.Visits it will display the cumulated number of hits and visits of the SharePoint 2010 site. Am i able to get the start time and date when the count of hits and visits started?

Leave a Reply

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