The .Net framework does not provide any function to compute the size of all the files in a folder (and its subfolders). As it is not very hard to do here's the code:
public static long FolderSize(string path)
long size = 0;
DirectoryInfo directoryInfo = new DirectoryInfo(path);
IEnumerable<FileInfo> files = directoryInfo.GetFiles("*", SearchOption.AllDirectories);
foreach (FileInfo file in files)
size += file.Length;
Do you have a question or a suggestion about this post? Contact me on Twitter or by email!