void Visit(DirStat dir) { Dictionary<string, CalcData> temp = new Dictionary<string, CalcData>(); Visit2(temp, dir); foreach (var item in temp) { ListModelData data = new ListModelData(item.Key, 0, string.Empty, item.Value.Bytes, 1.0 * item.Value.Bytes / dir.Length, item.Value.FileCount); items.Add(data); } }
void Visit2(Dictionary<string, CalcData> temp, DirStat dir) { foreach (var file in dir.Files) { string ext = Path.GetExtension(file.Name); CalcData data; if (!temp.TryGetValue(ext, out data)) { data = new CalcData(); temp.Add(ext, data); } data.Bytes += file.Length; data.FileCount++; } foreach (var subDir in dir.Directories) { Visit2(temp, subDir); } }
public DirStatModel(DirStat root) { this.root = root; }
internal DirectoryTreeModelData(DirStat dir) { this.dir = dir; }