private void Initialize(DirectoryInfo directory, uint level, ProgressDelegate Progress) { FileSystemInfo[] children = directory.GetFileSystemInfos(); if (children != null) { Progress?.Invoke(this, new ProgressEventArgs(0, children.Length)); int childNumberLength = children.Length.ToString().Length; for (int i = 0; i < children.Length; i++) { IsoFolderElement child; string childNumber = string.Format("{0:D" + childNumberLength.ToString() + "}", i); if (children[i].GetType() == typeof(DirectoryInfo)) { child = new IsoDirectory(this, (DirectoryInfo)children[i], level + 1, childNumber); } else { child = new IsoFile((FileInfo)children[i], childNumber); } Children.Add(child); Progress?.Invoke(this, new ProgressEventArgs(i)); } } Children.Sort(); CalculateSize(); }
private void Initialize(TreeNode directory, UInt32 level, ProgressDelegate Progress) { m_level = level; TreeNode[] children = directory.GetAllChildren(); if (children != null) { if (Progress != null) { Progress(this, new ProgressEventArgs(0, children.Length)); } int childNumberLength = children.Length.ToString().Length; for (int i = 0; i < children.Length; i++) { IsoFolderElement child; string childNumber = String.Format("{0:D" + childNumberLength.ToString() + "}", i); if (children[i].IsDirectory) { child = new IsoDirectory(this, children[i], level + 1, childNumber); } else { child = new IsoFile(children[i], childNumber); } m_children.Add(child); if (Progress != null) { Progress(this, new ProgressEventArgs(i)); } } m_children.Sort(); } this.CalculateSize(); }