float ratio = -1.0F; // ratio of new size to old size public FileNode(FileInfo fileInfo) { this.fileInfo = fileInfo; try { this.sizeUsed = fileInfo.Length; long clusterSize = ClusterSize.GetClusterSize(fileInfo.FullName); this.size = ((sizeUsed + clusterSize - 1) / clusterSize) * clusterSize; } catch (Exception) { //Console.WriteLine("Exception: {0}", e); } }
void DoPopulate(DirectoryNode rootDirectoryNode) { rootDirectoryNode.OnDirectoryScanned(this.directoryInfo.FullName); int clusterSize = ClusterSize.GetClusterSize(root); try { foreach (FileInfo f in directoryInfo.GetFiles()) { if (rootDirectoryNode.cancelled) { rootDirectoryNode.OnPopulateComplete(false); Thread.CurrentThread.Abort(); } rootDirectoryNode.OnFileScanned(f.FullName); FileNode fileNode = new FileNode(f); fileNode.Parent = this; this.files.Add(fileNode); } foreach (DirectoryInfo d in directoryInfo.GetDirectories()) { DirectoryNode dirNode = new DirectoryNode(d.FullName); dirNode.Parent = this; dirs.Add(dirNode); dirNode.DoPopulate(rootDirectoryNode); } } catch (ThreadAbortException) { //throw e; } catch (Exception e) { Console.WriteLine("Exception: {0}", e); } }