Click here to Skip to main content
15,879,535 members
Articles / Programming Languages / C#

Library and List Size

Rate me:
Please Sign up or sign in to vote.
0.00/5 (No votes)
8 Nov 2012CPOL3 min read 16.3K   133   2  
How to solve a real life scenario involving retrieving the size of libraries and lists.
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using Microsoft.SharePoint;

namespace SiteSizeApp
{
    public partial class MainForm : Form
    {
        public MainForm()
        {
            InitializeComponent();
        }

    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;
        }
    }
    }
}

By viewing downloads associated with this article you agree to the Terms of Service and the article's licence.

If a file you wish to view isn't highlighted, and is a text file (not binary), please let us know and we'll add colourisation support for it.

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)


Written By
Architect
United States United States
Jean Paul is a Microsoft MVP and Architect with 12+ years of experience. He is very much passionate in programming and his core skills are SharePoint, ASP.NET & C#.

In the academic side he do hold a BS in Computer Science & MBA. In the certification side he holds MCPD & MCTS spanning from .Net Fundamentals to SQL Server.

Most of the free time he will be doing technical activities like researching solutions, writing articles, resolving forum problems etc. He believes quality & satisfaction goes hand in hand.

You can find some of his work over here. He blogs at http://jeanpaulva.com

Comments and Discussions