C# Get Folder Size
Add a reference to the Microsoft Scripting Runtime and use:
string path = @"d:\folderpath"; Scripting.FileSystemObject fso = new Scripting.FileSystemObject(); Scripting.Folder folder = fso.GetFolder(path); long dirSize = (long)folder.Size;
Referencing this COM seems to be one of the fastest ways to get a folder size. I reached faster times with this than with recursive (SearchOption.AllDirectories) System.IO.DirectoryInfo > EnumerateFiles.
A quick test performed repeatedly on 30K files (6.5GB) internal 7200rpm 3.5 SATA:
EnumerateFiles: ~580 ms.