private void UpdateTree(FileSystemObjectInfo fileSystemObjectInfo) { fileSystemObjectInfo.ExploreFiles(); fileSystemObjectInfo.ExploreDirectories(); if (fileSystemObjectInfo.Children != null) { foreach (var child in fileSystemObjectInfo.Children) { child.ExploreDirectories(); child.ExploreFiles(); UpdateTree(child); } } }
private void ExploreFiles() { if (!ReferenceEquals(Drive, null)) { if (!Drive.IsReady) { return; } } try { if (FileSystemInfo is DirectoryInfo) { var files = ((DirectoryInfo)FileSystemInfo).GetFiles(); foreach (var file in files.OrderBy(d => d.Name)) { if (!Equals((file.Attributes & FileAttributes.System), FileAttributes.System) && !Equals((file.Attributes & FileAttributes.Hidden), FileAttributes.Hidden)) { if (file.Extension == ".inw") { var newFile = new FileSystemObjectInfo(file); var FilesInfo = new List <string>(); foreach (var dir in Children) { FilesInfo.Add(dir.FileSystemInfo.FullName); } if (!FilesInfo.Contains(newFile.FileSystemInfo.FullName)) { Children.Add(newFile); } } } } } } catch { /*throw;*/ } }
private void ExploreDirectories() { if (!ReferenceEquals(Drive, null)) { if (!Drive.IsReady) { return; } } try { if (FileSystemInfo is DirectoryInfo) { var directories = ((DirectoryInfo)FileSystemInfo).GetDirectories(); foreach (var directory in directories.OrderBy(d => d.Name)) { if (!Equals((directory.Attributes & FileAttributes.System), FileAttributes.System) && !Equals((directory.Attributes & FileAttributes.Hidden), FileAttributes.Hidden)) { var newDirectory = new FileSystemObjectInfo(directory); var directoriesInfo = new List <string>(); foreach (var dir in Children) { directoriesInfo.Add(dir.FileSystemInfo.FullName); } if (!directoriesInfo.Contains(newDirectory.FileSystemInfo.FullName)) { Children.Add(newDirectory); } } } } } catch { /*throw;*/ } }