public async Task <List <TransferDirectory> > AddDirectoriesToRoot(TransferDirectory transfer_directory) { return(await Task.Run(async() => { DirectoryInfo directory_root = new DirectoryInfo(transfer_directory.FullName); foreach (var directory in directory_root.GetDirectories()) { transfer_directory.Directories.Add(await GetPartDirectory(directory.FullName)); } return transfer_directory.Directories; })); }
private void AddFiles(DirectoryInfo directory, TransferDirectory userDirectory) { foreach (var file in directory.GetFiles()) { var transferFile = new TransferFile { Name = file.Name, FullName = file.FullName, Size = file.Length, Extension = file.Extension }; userDirectory.Files.Add(transferFile); } }
public async Task <TransferDirectory> GetPartDirectory(string directory_path) { DirectoryInfo directory = new DirectoryInfo(directory_path); TransferDirectory userDirectory = new TransferDirectory { Name = directory.Name, FullName = directory.FullName, TotalSize = await GetSizeDirectory(directory.FullName) }; AddFiles(directory, userDirectory); return(userDirectory); }
private async Task <DirectoryInfo[]> BuildRoot(string directory_path) { DirectoryInfo directory = new DirectoryInfo(directory_path); UserDirectory = new TransferDirectory { Name = directory.Name, FullName = directory.FullName, TotalSize = await GetSizeDirectory(directory.FullName) }; AddFiles(directory, UserDirectory); return(directory.GetDirectories()); }