FolderBrowserDialog folderBrowerDialog = new FolderBrowserDialog();
folderBrowerDialog.ShowDialog();
string selectedPath = folderBrowerDialog.SelectedPath;
string[] selectedDirectories = Directory.GetDirectories(selectedPath);
long size = 0;
foreach (var dir in selectedDirectories)
{
string[] files = Directory.GetFiles(dir);
foreach (var file in files)
{
FileInfo fileInfo = new FileInfo(file);
size += fileInfo.Length;
}
}
listBox1.Items.Add(size);