.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Articles >> SharePoint >> Post New Resource Bookmark and Share   

 Subscribe to Articles

Quick retrieval of Library, List Size in SharePoint 2010

Posted By:Jean Paul       Posted Date: October 31, 2013    Points: 200    Category: SharePoint    URL: http://www.dotnetspark.com  

In this article we can see how to solve a real life scenario involving retrieving size of libraries & lists.
 

In this article we can see how to solve a real life scenario involving retrieving size of libraries & lists.

Scenario

Your customer site collection exceeded 100 Giga Bytes in size.  You are assigned to create a Site Collection Size report that shows the Library & List entries along with the Size.  The report is crucial to take decisions on possible migration of items into separate site collection.

Solution

Following are the solutions possible:

  1. Iterate through each list / library entries and calculate size of file, file version, recycle bin.  This way would be time consuming and may timeout on large site collection execution.
  2. Use StorageManagementInformation() method for quicker retrieval

 

 

Implementation

For implementing the solution using the second approach:

  • Create a Windows Forms application
  • Add reference to Microsoft.SharePoint assembly
  • Set the project property > build > target platform to Any CPU

.  Add the following controls to the main form.

On click of the execute button add the following code.

    private void ExecuteButton_Click(object sender, EventArgs e)

    {

        using (SPSite site = new SPSite(UrlText.Text))

        {

            // Retrieve Document Library entries

            DataTable table = site.StorageManagementInformation(

                SPSite.StorageManagementInformationType.DocumentLibrary, 

                SPSite.StorageManagementSortOrder.Decreasing, 

                SPSite.StorageManagementSortedOn.Size, 

                1000

                );

 

            // Retrieve List entries

            table.Merge(site.StorageManagementInformation(

                SPSite.StorageManagementInformationType.List,

                SPSite.StorageManagementSortOrder.Decreasing,

                SPSite.StorageManagementSortedOn.Size,

                1000)

                );

 

            grid.DataSource = table;

        }

    }

Squadron for SharePoint 2010

A SharePoint utility application is created with the above functionality.  You can download it from:

http://squadron2010.codeplex.com/

Following is the screen shot on execution of Squadron:

For retrieving Site Collection Size information, click on the Site Size item from the left pane and then the Execute button.  You should get the result as shown below.

For saving the result, please proceed with the next section.

 

Saving the Report

Squadron provides infrastructure to save the report.  You can right click on the grid and choose the Export Data option as shown below:

You will be prompted to enter the CSV (Comma Separated Values) file location.

After saving, the file gets opened in the appropriate file handler in your machine.

Advanced Export

The advanced export feature allows selection of columns while exporting.  You can use the Export Data button on the right top end for this purpose.  For testing with click the User Profile item and then the Execute button.

In the appearing screen, choose the columns you would like to export:

 

 

You can even right click for Check All / Uncheck All options as shown below:

After choosing the necessary columns, choose the OK buttonYou should get the prompt for CSV file path.

After saving, the file gets opened in the register file handler for CSV files.

This concludes our awareness with Advanced Export feature.

References

http://www.sharepointcto.com/Squadron

Summary

In this article we have explored a quicker approach in retrieving site collection size entries. I hope the information is useful and please note that the above information is available through Central Administration as well. The method StorageManagementInformation() is a deprecated one and should not be used with very large row count parameter, as it may raise memory issues.  The source code for the article is attached. 

The Squadron tool is free and it contains other utilities too for working with SharePoint 2010.  In future I believe there will be more and more utilities available as Squadron core is built using plugin based architecture.


 Subscribe to Articles

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More Articles on C#, ASP.Net, Vb.Net, SQL Server and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend