async Task StartDownloadFileAsync(string username, string password, string filepath) { FileDownload temp = new FileDownload(); temp = await RestAPIs.DownloadFile(username, username, filepath); var path = WorkingFolder; if (path.EndsWith("\\")) { path = path.Substring(0, path.Length - 2); } if (temp.FilePath.StartsWith("\\")) { temp.FilePath = temp.FilePath.Substring(1); } path += "\\" + temp.FilePath; new System.IO.DirectoryInfo(path).Create(); if (path.EndsWith("\\")) { path = path.Substring(0, path.Length - 2); } File.WriteAllBytes(path + "\\" + temp.FileName, temp.FileContent); updatedFile++; progressBar.Value = (updatedFile / FolderData.Count) * 100; }
async Task StartGetAllFileInformationAsyncAsync() { FolderData = await RestAPIs.GetAllFileInformationAsync(_clientInfor.UserInfor.Username, _clientInfor.UserInfor.Password, "root"); bgwSync = new BackgroundWorker(); bgwSync.WorkerReportsProgress = true; bgwSync.WorkerSupportsCancellation = true; bgwSync.DoWork += BgwSync_DoWork; bgwSync.ProgressChanged += BgwSync_ProgressChanged; bgwSync.RunWorkerCompleted += BgwSync_RunWorkerCompleted; updatedFile = 0; bgwSync.RunWorkerAsync(); RenderControl(); }