views:

284

answers:

1

I have an SPList item in sharepoint and I want to find out the size on disk of the list. Is it possible without going through each item in the list and trying to find out the size?

Update

Below is the code I think I can use if I do need to get each item:

        long listSize = 0;
        foreach (SPListItem item in list.Items)
        {
            listSize += item.File.Length;
        }

Update

I think I will need to go through each item to work out the size. How would you recommend doing this? I need to get the file size, any data in the fields size and and additions versions held.

A: 

You could do a CAML query and retrieve all of the list item's file sizes. That way, you can constraint the returned fields to just the file size, and just add up all the file sizes in the resultant DataTable.

This article can give you a nice overview on CAML queries using the SharePoint object model.

Disclaimer: I've haven't tried this, but I have worked with CAML, and I don't see any reason why this wouldn't work.

Steve Danner