public async void CreateFolder(FileTreeNode folderIn, string name) { CheckAutorization(); await _client.CreateFolderTask(String.Format("{0}/{1}", folderIn.IsDirectory ? folderIn.Path : Path.GetDirectoryName(folderIn.Path).Replace('\\', '/'), name).TrimEnd('/'), null, null); }
public async Task<FileTreeNode> GetFiles() { CheckAutorization(); var rootDir = new FileTreeNode { Name = "Dropbox", Path = "/", IsDirectory = true }; await LoadFilesTree(rootDir, "/"); return rootDir; }
private async Task LoadFilesTree(FileTreeNode rootFileTreeNode, String path) { var currentFolder = (await _client.GetMetaDataTask(path: path)).Contents; if (currentFolder != null) foreach (var content in currentFolder) { var dir = new FileTreeNode {Name = content.Name, Path = content.Path}; rootFileTreeNode.Children.Add(dir); if (content.Is_Dir) dir.IsDirectory = true; await LoadFilesTree(dir, Path.Combine(path, dir.Name).Replace('\\', '/')); } }
public async void UploadFile(FileTreeNode folderTo, byte[] data, string name = "auto_name") { CheckAutorization(); await _client.UploadFileTask(folderTo.Path, folderTo.IsDirectory ? name : folderTo.Name, data); }
public async Task<byte[]> DownloadFile(FileTreeNode file) { CheckAutorization(); return (await _client.GetFileTask(file.Path)).RawBytes; }