我將內容數據庫的大小限制在200 GB以內。我已經使用下面的代碼來獲取內容數據庫的大小。如何通過C#獲取網站集的大小?
SPWebApplication elevatedWebApp = spWeb.Site.WebApplication;
SPContentDatabaseCollection dbCollection = elevatedWebApp.ContentDatabases;
//Guid id = dbCollection[0].Id;
Guid lastContentDbGuid = new Guid(contentDbGuid);
//SPContentDatabase lastDatabase = dbCollection[dbCollection.Count - 1];
SPContentDatabase lastDatabase = dbCollection[lastContentDbGuid];
ulong dbSize = lastDatabase.DiskSizeRequired;
contentDbMB = ConvertToMegabytes(dbSize);
static string ConvertToMegabytes(ulong bytes)
{
return ((decimal)bytes/1024M/1024M).ToString("F1") + "MB";
}
與之相似我想限制網站集高達100 GB。所以我用下面的代碼
long bytes = spSite.Usage.Storage;
double siteCollectionSizeInMB = ConvertBytesToMegabytes(bytes);
>
static double ConvertBytesToMegabytes(long bytes)
{
return (bytes/1024f)/1024f;
}
我只用C#需要集合的大小。我做對了嗎?如果我做錯了什麼,請指導我。如果有人有不同的解決方案,那麼請分享。