Search code examples
c#.netfilesystems

What is the fastest way to calculate a Windows folders size?


I need to calculate the size of hundreds of folders, some will be 10MB some maybe 10GB, I need a super fast way of getting the size of each folder using C#.

My end result will hopefully be:

Folder1 10.5GB

Folder2 230MB

Folder3 1.2GB

...


Solution

  • There is no simple way to do this in .Net; you will have to loop through every file and subdir. See the examples here to see how it's done.