Example #1
0
 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);
 }
Example #2
0
 public async Task<FileTreeNode> GetFiles()
 {
     CheckAutorization();
     var rootDir = new FileTreeNode { Name = "Dropbox", Path = "/", IsDirectory = true };
     await LoadFilesTree(rootDir, "/");
     return rootDir;
 }
Example #3
0
 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('\\', '/'));
         }
 }
Example #4
0
 public async void UploadFile(FileTreeNode folderTo, byte[] data, string name = "auto_name")
 {
     CheckAutorization();
     await _client.UploadFileTask(folderTo.Path, folderTo.IsDirectory ? name : folderTo.Name, data);
 }
Example #5
0
 public async Task<byte[]> DownloadFile(FileTreeNode file)
 {
     CheckAutorization();
     return (await _client.GetFileTask(file.Path)).RawBytes;
 }