protected async Task <SmartItem[]> _prepareForUpload(string[] items, string destination) { List <SmartItem> uploadList = new List <SmartItem>(); IList <string> folders = new List <string>(); await Task.Run(async delegate { for (int i = 0; i < items.Length; i++) { if (Paused) { while (Paused && !IsCanceled) { await Task.Delay(200); } } if (IsCanceled) { break; } if (FileHelper.Exists(items[i])) { FileInfo file = null; try { file = new FileInfo(items[i]); uploadList.Add(new SmartItem(file, destination)); TransferEvent.TotalSize += file.Length; TransferEvent.TotalFiles++; } catch (Exception exp) { ExceptionHelper.Log(exp); } file = null; } else if (DirectoryHelper.Exists(items[i])) { folders.Add(items[i]); } } items = null; for (int i = 0; i < folders.Count; i++) { if (Paused) { while (Paused && !IsCanceled) { await Task.Delay(200); } } if (IsCanceled) { break; } uploadList.AddRange(await _getLocalItems(new DirectoryInfo(folders[i]), destination, -1, uploadList.Count)); } folders = null; }); if (IsCanceled) { return new SmartItem[] { } } ; return(uploadList.ToArray()); }
protected async Task <SmartItem[]> _getLocalItems(DirectoryInfo dir, string destination, int parentID, int count) { List <SmartItem> uploadList = new List <SmartItem>(); await Task.Run(async delegate { uploadList.Add(new SmartItem(dir, destination, parentID)); TransferEvent.TotalFolders++; parentID = parentID + count + 1; FileInfo[] files = null; try { files = dir.GetFiles(); for (int i = 0; i < files.Length; i++) { if (Paused) { while (Paused && !IsCanceled) { await Task.Delay(200); } } if (IsCanceled) { break; } uploadList.Add(new SmartItem(files[i], destination + dir.Name + '/', parentID)); TransferEvent.TotalSize += files[i].Length; TransferEvent.TotalFiles++; } } catch (Exception exp) { ExceptionHelper.Log(exp); } files = null; DirectoryInfo[] dirs = null; try { dirs = dir.GetDirectories(); for (int i = 0; i < dirs.Length; i++) { if (Paused) { while (Paused && !IsCanceled) { await Task.Delay(200); } } if (IsCanceled) { break; } uploadList.AddRange(await _getLocalItems(dirs[i], destination + dir.Name + '/', parentID, uploadList.Count - 1)); } } catch (Exception exp) { ExceptionHelper.Log(exp); } dirs = null; dir = null; }); if (IsCanceled) { return new SmartItem[] { } } ; return(uploadList.ToArray()); }
internal static void GetNewApp() { try { System.Diagnostics.Process.Start(VersionHelper.NewAppUrl); } catch (Exception exp) { ExceptionHelper.Log(exp); } }