Пример #1
0
        private FolderResult GetFolderResult(string targetPath)
        {
            var result = new FolderResult();

            foreach (var dirPath in Directory.GetDirectories(targetPath))
            {
                var dirInfo = new DirectoryInfo(dirPath);

                if (this.Config.ExcludeDirectories.Contains(dirInfo.Name)) continue;

                result.Folders.Add(new Folder
                {
                    Name = dirInfo.Name,
                    ModifiedDate = dirInfo.LastWriteTimeUtc,
                    FileCount = dirInfo.GetFiles().Length
                });
            }

            foreach (var filePath in Directory.GetFiles(targetPath))
            {
                var fileInfo = new FileInfo(filePath);

                result.Files.Add(new ServiceModel.Types.File
                {
                    Name = fileInfo.Name,
                    Extension = fileInfo.Extension,
                    FileSizeBytes = fileInfo.Length,
                    ModifiedDate = fileInfo.LastWriteTimeUtc,
                    IsTextFile = Config.TextFileExtensions.Contains(fileInfo.Extension),
                });
            }

            return result;
        }
Пример #2
0
        private FolderResult GetFolderResult(string targetPath)
        {
            var result = new FolderResult();

            var dir = VirtualFiles.GetDirectory(targetPath);
            foreach (var subDir in dir.Directories)
            {
                if (Config.ExcludeDirectories.Contains(subDir.Name)) continue;

                result.Folders.Add(new Folder
                {
                    Name = subDir.Name,
                    ModifiedDate = subDir.LastModified,
                    FileCount = subDir.GetFiles().Count(),
                });
            }

            foreach (var fileInfo in dir.GetFiles())
            {
                result.Files.Add(new ServiceModel.Types.File
                {
                    Name = fileInfo.Name,
                    Extension = fileInfo.Extension,
                    FileSizeBytes = fileInfo.Length,
                    ModifiedDate = fileInfo.LastModified,
                    IsTextFile = Config.TextFileExtensions.Contains(fileInfo.Extension),
                });
            }

            return result;
        }