Example #1
0
 private void fileList_Drop(object sender, DragEventArgs e)
 {
     try {
         FTPLibrary ftpLib = new FTPLibrary(userNameBox.Text, passwordBox.Password, isSecureConnection);
         int count = 0;
         string log = "";
         if (e.Data is System.Windows.DataObject &&
             ((System.Windows.DataObject)e.Data).ContainsFileDropList()) {
             foreach (string filePath in ((System.Windows.DataObject)e.Data).GetFileDropList()) {
                 double size = ftpLib.GetFTPSize(ftpBox.Text + "/" + System.IO.Path.GetFileName(filePath));
                 if (size > 0) {
                     MessageBoxResult r;
                     r = MessageBox.Show("The file: '" + System.IO.Path.GetFileName(filePath) +
                         "' already exist on this server, do you want to overwrite?", "File exist",
                         MessageBoxButton.YesNo, MessageBoxImage.Question, MessageBoxResult.No);
                     if (r == MessageBoxResult.Yes) {
                         log = ftpLib.Upload(ftpBox.Text + "/" + System.IO.Path.GetFileName(filePath), filePath);
                         count++;
                     }
                 }
                 else {
                     log = ftpLib.Upload(ftpBox.Text + "/" + System.IO.Path.GetFileName(filePath), filePath);
                     fileList.Items.Add(System.IO.Path.GetFileName(filePath));
                     count++;
                 }
             }
         }
         if (log.StartsWith("Error"))
             ShowStatus(log);
         else
             ShowStatus("Succesfully uploaded " + count + " files at '" + ftpBox.Text + "'");
     }
     catch (Exception ex){
         ShowStatus(ex.Message);
     }
 }