SPSite.Usage property
SharePoint 2013
Gets information about site usage, including bandwidth, storage, and number of visits to the site collection.
Assembly: Microsoft.SharePoint (in Microsoft.SharePoint.dll)
[SubsetCallableExcludeMemberAttribute(SubsetCallableExcludeMemberType.Struct)] public SPSite.UsageInfo Usage { get; }
Property value
Type: Microsoft.SharePoint.SPSite.UsageInfoAn SPSite.UsageInfo structure that contains the usage information.
The following code example iterates through all the site collections in a Web application and displays the URL and amount of storage used in each.
Uri uriNew = new Uri("http://MyServer"); SPWebApplication oWebApp = SPWebApplication.Lookup(uriNew); SPSiteCollection collSiteCollection = oWebApp.Sites; foreach (SPSite oSiteCollection in collSiteCollection) { SPSite.UsageInfo oUsageInfo = oSiteCollection.Usage; long lngStorageUsed = oUsageInfo.Storage; Response.Write("Site Collection URL: " + oSiteCollection.Url + " Storage: " + lngStorageUsed.ToString() + "<BR>"); oSiteCollection.Dispose(); }
Note
|
|---|
Certain objects implement the IDisposable interface, and you must avoid retaining these objects in memory after they are no longer needed. For information about good coding practices, see Disposing Objects. |
Note