示例#1
0
 public static async Task <FileSystemDrive> UpdateFolderAsync(FileSystemDrive fileSystemDrive, FileSystemDirectory targetDirectory, IProgress <StorageManagerProgress> progress)
 {
     return(await Task.Run(() => UpdateFolder(fileSystemDrive, targetDirectory)));
 }
示例#2
0
 private static FileSystemDrive UpdateFolder(FileSystemDrive fileSystemDrive, FileSystemDirectory targetDirectory)
 {
     return(fileSystemDrive);
 }
示例#3
0
            private FileSystemDirectory GetFileSystemDirectory(DirectoryInfo rootDirectoryInfo, int level, int maxLevelToUpdateProgress)
            {
                FileSystemDirectory fileSystemDirectory = new FileSystemDirectory
                {
                    Name         = rootDirectoryInfo.Name,
                    CreateDate   = rootDirectoryInfo.CreationTime,
                    ModifiedDate = rootDirectoryInfo.LastWriteTime
                };

                if (!_runThMain)
                {
                    return(fileSystemDirectory);
                }

                try
                {
                    var fileInfoArr = rootDirectoryInfo.GetFiles();
                    fileSystemDirectory.FilesTotal = fileInfoArr.Length;
                    if (fileInfoArr.Length > 0)
                    {
                        fileSystemDirectory.FileList = new List <FileSystemFile>();
                        foreach (FileInfo file in fileInfoArr)
                        {
                            fileSystemDirectory.FileList.Add(new FileSystemFile
                            {
                                Name           = file.Name,
                                FullName       = file.FullName,
                                FileSize       = file.Length,
                                FileAttributes = file.Attributes,
                                CreateDate     = file.CreationTime,
                                ModifiedDate   = file.LastWriteTime,
                                LastAccessDate = file.LastAccessTime
                            });
                            fileSystemDirectory.FileSizeTotal += file.Length;
                        }
                    }

                    var subDirArr = new DirectoryInfo(rootDirectoryInfo.FullName).GetDirectories().Where(dir => !dir.Attributes.HasFlag(FileAttributes.ReparsePoint)).ToArray();
                    fileSystemDirectory.SubDirectoriesTotal = subDirArr.Length;
                    if (subDirArr.Length > 0)
                    {
                        fileSystemDirectory.DirectoryList = new List <FileSystemDirectory>();
                        foreach (DirectoryInfo dir in subDirArr)
                        {
                            if (level <= maxLevelToUpdateProgress)
                            {
                                _currentProgress++;
                            }

                            //if (!dir.Attributes.HasFlag(FileAttributes.Directory) || dir.Attributes.HasFlag(FileAttributes.ReparsePoint))
                            //    continue;

                            FileSystemDirectory subDirectory = GetFileSystemDirectory(dir, level + 1, maxLevelToUpdateProgress);
                            fileSystemDirectory.FileSizeTotal       += subDirectory.FileSizeTotal;
                            fileSystemDirectory.SubDirectoriesTotal += subDirectory.SubDirectoriesTotal;
                            fileSystemDirectory.FilesTotal          += subDirectory.FilesTotal;

                            fileSystemDirectory.DirectoryList.Add(subDirectory);
                        }
                    }
                }
                catch
                {
                    fileSystemDirectory.SubDirAccessDenied = true;
                }

                return(fileSystemDirectory);
            }