private void DoWork(string selectedPath) { FolderData fd = new FolderData(selectedPath); listBox.Items.Add(fd); DirectoryInfo di = new DirectoryInfo(selectedPath); CollectDirs(di, fd); }
private void CollectDirs(DirectoryInfo di, FolderData fd) { try { foreach (var file in di.GetFiles()) { try { fd.Bytes += file.Length; } catch { } } } catch { } try { foreach (var d in di.GetDirectories()) { CollectDirs(d, fd); } } catch { } }