List <AbstractFile> GetFileSystemList(string FsPath) { List <AbstractFile> FilesList = new List <AbstractFile>(); //FileSystemFilesAndFolders.Clear(); string[] files = Directory.GetFiles(FsPath); string[] directory = Directory.GetDirectories(FsPath); int index = 0; if (!String.IsNullOrEmpty(FsPath) && FsPath.Length > 3) { FilesList.Add(new ConcreteFolder()); ConcreteFolder UpFolder = (ConcreteFolder)FilesList[0]; UpFolder.FolderName = ".."; UpFolder.FolderPath = FsPath.Remove(FsPath.LastIndexOf(@"\"), FsPath.Length - FsPath.LastIndexOf(@"\")); FilesList[0] = UpFolder; index = 1; } foreach (string obj in directory) { if (Directory.Exists(obj)) { FilesList.Add(Creator.GetNew(FileDir.Folder)); ConcreteFolder fld = (ConcreteFolder)FilesList[index]; fld.FolderName = obj.Remove(0, obj.LastIndexOf('\\') + 1); fld.FolderPath = Path.GetFullPath(obj); FilesList[index] = fld; index++; } } foreach (string obj in files) { if (File.Exists(obj)) { FilesList.Add(Creator.GetNew(FileDir.File)); ConcreteFile fle = (ConcreteFile)FilesList[index]; fle.FileName = Path.GetFileName(obj); fle.FilePath = Path.GetFullPath(obj); fle.FileSize = new FileInfo(obj).Length / 1024; FilesList[index] = fle; index++; } } index = 0; return(FilesList); }
public async Task <List <AbstractFile> > GetList(string path) { if (String.IsNullOrEmpty(path)) { path = string.Empty; } List <AbstractFile> FilesList = new List <AbstractFile>(); ListFolderResult list = await client.Files.ListFolderAsync(path); int index = 0; if (!String.IsNullOrEmpty(path) && path != "/") { FilesList.Add(Creator.GetNew(FileDir.Folder)); ConcreteFolder UpFolder = (ConcreteFolder)FilesList[0]; UpFolder.FolderName = ".."; UpFolder.FolderPath = path.Remove(path.LastIndexOf(@"/"), path.Length - path.LastIndexOf(@"/")); FilesList[0] = UpFolder; index = 1; } foreach (var item in list.Entries.Where(i => i.IsFolder)) { FilesList.Add(Creator.GetNew(FileDir.Folder)); ConcreteFolder fle = (ConcreteFolder)FilesList[index]; fle.FolderName = item.Name; fle.FolderPath = item.PathLower; FilesList[index] = fle; index++; } foreach (var item in list.Entries.Where(i => i.IsFile)) { FilesList.Add(Creator.GetNew(FileDir.File)); ConcreteFile fle = (ConcreteFile)FilesList[index]; fle.FileName = item.Name; fle.FilePath = item.PathLower; FilesList[index] = fle; index++; } index = 0; return(FilesList); }