private void onDrop(object sender, DragEventArgs e)
 {
     if (!e.Data.GetDataPresent(DataFormats.FileDrop)) {
         return;
     }
     ProgressDialog progress = new ProgressDialog();
     var context = TaskScheduler.FromCurrentSynchronizationContext();
     Task task = Task.Factory.StartNew(() => {
         string[] filePath = (string[])e.Data.GetData(DataFormats.FileDrop);
         foreach (var path in filePath) {
             if (Directory.Exists(path)) {
                 DirectoryInfo dirInfo = new DirectoryInfo(path);
                 PushFile(path, CurrentPath + "/" + dirInfo.Name);
             } else if (File.Exists(path)) {
                 PushFile(path, CurrentPath);
             }
         }
     });
     task.ContinueWith(x => {
         progress.Dispose();
         RefreshFileList();
     }, context);
     progress.ShowDialog(this);
 }
        private void PullAndEditFile(string destPath, FileInfo fileInfo)
        {
            if (!Directory.Exists(destPath)) {
                Directory.CreateDirectory(destPath);
            }

            string destFileAbsolutePath = destPath + fileInfo.GetFileName();
            string result = PullFile(destPath, fileInfo);
            bool isModifiedFile = StartProcess(destFileAbsolutePath);
            if (isModifiedFile) {

                DialogResult dialogResult = MessageBox.Show(Resources.DetectedFileHasModified, Resources.Confirm, MessageBoxButtons.YesNo);
                if (dialogResult == DialogResult.Yes) {
                    ProgressDialog progress = new ProgressDialog();
                    var context = TaskScheduler.FromCurrentSynchronizationContext();
                    Task task = Task.Factory.StartNew(() => {
                        PushFile(destFileAbsolutePath, fileInfo);
                    });
                    task.ContinueWith(x => {
                        progress.Dispose();
                        RefreshFileList();
                    }, context);
                    progress.ShowDialog(this);
                }
            }
        }
 private void onMenuSelected_SelectFileDownload(object sender, EventArgs e)
 {
     var items = this.listView.SelectedItems;
     IList<FileInfo> fileInfoList = new List<FileInfo>();
     foreach (ListViewItem item in items) {
         fileInfoList.Add((FileInfo)item.Tag);
     }
     CommonOpenFileDialog dialog = new CommonOpenFileDialog();
     dialog.IsFolderPicker = true;
     dialog.EnsureReadOnly = false;
     dialog.Multiselect = false;
     dialog.AllowNonFileSystemItems = false;
     var result = dialog.ShowDialog();
     if (result == CommonFileDialogResult.Ok) {
         ProgressDialog progress = new ProgressDialog();
         var context = TaskScheduler.FromCurrentSynchronizationContext();
         Task task = Task.Factory.StartNew(() => {
             string dest = dialog.FileName;
             foreach (var fileInfo in fileInfoList) {
                 PullFile(dest, fileInfo);
             }
         });
         task.ContinueWith(x => {
             progress.Dispose();
             RefreshFileList();
         }, context);
         progress.ShowDialog(this);
     }
 }