private async void button3_Click(object sender, EventArgs e) { Metadata item; if (treeView.SelectedNode != null && (item = treeView.SelectedNode.Tag as Metadata).IsFile | item.IsFolder) { SelectFolderWindow sfw = new SelectFolderWindow(); if (sfw.ShowDialog()) { try { await Client.Files.Copy(item.Path, sfw.FolderPath + "/" + item.Name); } catch (DropboxException ex) // catch any other exception { MessageBox.Show(string.Format("An error of type {0} occured while trying to download the file: {1}", ex.GetType(), ex.Message), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } else { MessageBox.Show("Please select a file or folder to copy."); } }
private async void uploadButton_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == DialogResult.OK) { SelectFolderWindow sfw = new SelectFolderWindow(); if (sfw.ShowDialog()) { try { await Client.Files.Upload(ofd.FileName, sfw.FolderPath + "/" + Path.GetFileName(ofd.FileName), WriteMode.Add, false, false); } catch (OperationCanceledException) // check if user canceled operation { MessageBox.Show("Operation canceled!", "Operation canceled!", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (DropboxException ex) // catch any other exception { MessageBox.Show(string.Format("An error of type {0} occured while trying to upload the file: {1}", ex.GetType(), ex.Message), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }
private async void uploadButton_Click(object sender, EventArgs e) { OpenFileDialog ofd = new OpenFileDialog(); if (ofd.ShowDialog() == DialogResult.OK) { SelectFolderWindow sfw = new SelectFolderWindow(); if (sfw.ShowDialog()) { try { await Client.Files.Upload(ofd.FileName, sfw.FolderPath + "/" + Path.GetFileName(ofd.FileName), WriteMode.Add, false, false); } catch(OperationCanceledException) // check if user canceled operation { MessageBox.Show("Operation canceled!", "Operation canceled!", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (DropboxException ex) // catch any other exception { MessageBox.Show(string.Format("An error of type {0} occured while trying to upload the file: {1}", ex.GetType(), ex.Message), "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error); } } } }