You will need to recursively list the files in the folder and summarize the file sizes. Remember to include system and hidden files for the correct size.
Here is a simple version:
long GetFolderSize(string path) { DirectoryInfo d = new DirectoryInfo(path); var files = d.GetFiles("*", SearchOption.AllDirectories); return files.Sum(fi => fi.Length); }
Remember that a file can take up more disk space than its length, because the file always takes up integer numbers of blocks in the file system (in case it matters to your application).
driis source share