3

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.

Linda
  • 2,227
  • 5
  • 30
  • 40
  • What do you mean by size? Do you want the number of items in the list or the physical size the list items are taking up? – Steve Danner Feb 15 '10 at 14:32
  • Some threads on this post might give you some ideas: http://stackoverflow.com/questions/936167/how-do-i-determine-the-size-of-a-sharepoint-list – dugas Feb 15 '10 at 14:56
  • Apart from http://stackoverflow.com/questions/936167/how-do-i-determine-the-size-of-a-sharepoint-list/937094#937094 I am not sure how I could do this by code. – Linda Feb 15 '10 at 15:49

1 Answers1

2

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
  • 21,818
  • 7
  • 41
  • 51