we were having the document library in the site and wants to fixed the size of the document library. So every time the user uploads any document size has to checked if the size goes above the certain limit it should show the error to the user .
We have written the following code to achieve this :
We have written the following code to achieve this :
DataTable dt;
dt = site.StorageManagementInformation(SPSite.StorageManagementInformationType.DocumentLibrary,SPSite.StorageManagementSortOrder.Decreasing,SPSite.StorageManagementSortedOn.Size, 100);
foreach (DataRow row in dt.Rows)
{
foreach (DataColumn column in dt.Columns)
{
if (row["Title"] == "DocumentLibraryName")
{
//Compare the size in bytes
if (Convert.ToUInt32(row["Size"]) == 1000)
{
//Code to perform the operation
}
}
}
In the StorageManagementInformation we can pass the StorageManagementInformationType.DocumentLibrary, List or Document