Beispiel #1
0
        private void deleteToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (lstRemoteSiteFiles.SelectedItems[0] != null)
            {
                //Check if File or Folder
                if (lstRemoteSiteFiles.SelectedItems[0].SubItems[1].Text == "File")
                {
                    try
                    {
                        //Delete the FILE
                        FtpClient.FtpDelete(lstRemoteSiteFiles.SelectedItems[0].Text);
                    }
                    catch (Exception ex)
                    {
                        TaskDialog.Show("Error Occured while Deleting File.  Error Message: " + ex.Message);
                    }
                }
                else
                {
                    try
                    {
                        //Delete the FOLDER
                        FtpClient.FtpDeleteDirectory(lstRemoteSiteFiles.SelectedItems[0].SubItems[2].Text);
                    }
                    catch (Exception ex)
                    {
                        TaskDialog.Show("Error Occured while Deleting File.  Error Message: " + ex.Message);
                    }
                }

                RefreshDirectory();
            }
        }
Beispiel #2
0
 private void button49_Click(object sender, EventArgs e)
 {
     try
     {
         string    str       = "Connexion : Ok";
         bool      flag      = false;
         FTPclient fTPclient = new FTPclient()
         {
             Retry = 0
         };
         try
         {
             fTPclient.Hostname         = this.tFTPServ.Text;
             fTPclient.Username         = this.tFTPLog.Text;
             fTPclient.Password         = this.tFTPPass.Text;
             fTPclient.UseSSL           = this.cFTPSSL.Checked;
             fTPclient.CurrentDirectory = this.tFTPRacine.Text;
             fTPclient.ListDirectory("");
         }
         catch (Exception exception1)
         {
             ProjectData.SetProjectError(exception1);
             Exception exception = exception1;
             Interaction.MsgBox(string.Concat("Erreur lors de la connexion au serveur FTP, vérifier que vous avez accès au serveur FTP via un client FTP (FileZilla, InternetExplorer, ...)\r\n", exception.Message), MsgBoxStyle.Critical, null);
             ProjectData.ClearProjectError();
             return;
         }
         try
         {
             fTPclient.ListDirectory("");
             str = string.Concat(str, "\r\nListe des fichiers : OK");
         }
         catch (Exception exception2)
         {
             ProjectData.SetProjectError(exception2);
             str  = string.Concat(str, "\r\nErreur lors de la liste des fichiers : ", exception2.Message);
             flag = true;
             ProjectData.ClearProjectError();
         }
         try
         {
             fTPclient.FtpCreateDirectory("MG2S_FTP_CLIENT_TEST");
             str = string.Concat(str, "\r\nCreation de répertoire : OK");
         }
         catch (Exception exception3)
         {
             ProjectData.SetProjectError(exception3);
             str  = string.Concat(str, "\r\nErreur lors de la creation de répertoire : ", exception3.Message);
             flag = true;
             ProjectData.ClearProjectError();
         }
         try
         {
             fTPclient.FtpDeleteDirectory("MG2S_FTP_CLIENT_TEST");
             str = string.Concat(str, "\r\nSuppression de répertoire : OK");
         }
         catch (Exception exception4)
         {
             ProjectData.SetProjectError(exception4);
             str  = string.Concat(str, "\r\nErreur lors de la suppression de répertoire : ", exception4.Message);
             flag = true;
             ProjectData.ClearProjectError();
         }
         if (!flag)
         {
             Interaction.MsgBox("Connexion et tests de transfert réussi.", MsgBoxStyle.Information, this.Text);
         }
         else
         {
             Interaction.MsgBox(str, MsgBoxStyle.Exclamation, this.Text);
         }
     }
     catch (Exception exception6)
     {
         ProjectData.SetProjectError(exception6);
         Exception exception5 = exception6;
         Interaction.MsgBox(exception5.Message, MsgBoxStyle.Critical, this.Text);
         ProjectData.ClearProjectError();
     }
 }