Not of the site collection itself, but the individual SPWeb's.
Asked
Active
Viewed 5,100 times
2 Answers
7
You should take a look at this blog entry by Alexander Meijers : Size of SPWeb based on its Folders and Files
It provides a clever way of finding the size of an SPWeb or SPFolder by iterating through his content.
private long GetWebSize(SPWeb web)
{
long total = 0;
foreach (SPFolder folder in web.Folders)
{
total += GetFolderSize(folder);
}
foreach (SPWeb subweb in web.Webs)
{
total += GetWebSize(subweb);
subweb.Dispose();
}
return total;
}

Pascal Paradis
- 4,275
- 5
- 37
- 50
-
The article doesn't exist anymore and the code is missing GetFolderSize. There is a discussion with that code here: http://social.msdn.microsoft.com/forums/en-us/sharepointdevelopment/thread/0d066e9b-f6b9-49bc-b741-fcf7abdc854b – Michael Stum Jun 27 '11 at 22:09
0
For anyone who comes back to this question, here is the missing method:
private long GetFolderSize(SPFolder folder)
{
long folderSize = 0;
foreach (SPFile file in folder.Files)
{
folderSize += file.Length;
}
foreach (SPFolder subfolder in folder.SubFolders)
{
folderSize += GetFolderSize(subfolder);
}
return folderSize;
}

JasonV
- 223
- 1
- 8