示例#1
0
        internal static FolderEntry FromFolderEntry(string entry, FileSystem fileSystem)
        {
            var folder = new FolderEntry();

            folder.Id          = fileSystem.GeneratePathId(entry);
            folder._fileSystem = fileSystem;
            folder.Name        = System.IO.Path.GetFileName(entry);
            folder.Path        = entry;
            folder.IsFolder    = true;
            var info = new DirectoryInfo(entry);

            folder.DateCreated  = info.CreationTime;
            folder.DateModified = info.LastWriteTime;

            foreach (var folderEntry in Directory.EnumerateDirectories(entry))
            {
                folder.Folders.Add(FromFolderEntry(folderEntry, fileSystem));
            }

            foreach (var fileEntry in Directory.EnumerateFiles(entry))
            {
                folder.Files.Add(FileEntry.FromFileEntry(fileEntry, fileSystem));
            }

            folder.FileSizeSummary = fileSystem.GetFileSizeSummary(folder.Files);

            return(folder);
        }
示例#2
0
        public void Load()
        {
            foreach (var entry in Directory.EnumerateDirectories(Root))
            {
                Folders.Add(FolderEntry.FromFolderEntry(entry, this));
            }

            foreach (var entry in Directory.EnumerateFiles(Root))
            {
                Files.Add(FileEntry.FromFileEntry(entry, this));
            }

            IsLoaded = true;
        }