I am creating application in Winform which among other things will also need to have the ability to calculate size of the folder.
Can someone give me pointers how to do that?
thanks
I use the following extension method to do that:
public static long Size(this DirectoryInfo Directory, bool Recursive = false)
{
if (Directory == null)
throw new ArgumentNullException("Directory");
return Directory.EnumerateFiles("*", Recursive ? SearchOption.AllDirectories : SearchOption.TopDirectoryOnly).Sum(x => x.Length);
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With