public void Supprimer(ITransfer transfer) { using (_monFtp = new Ftp()) { _monFtp.Connect(_maConfig.Host, _maConfig.Port); _monFtp.Login(_maConfig.Login, _maConfig.MotDePass); string resteChemin = MethodesGlobales.GetCheminServerSansRacinne(transfer.GetPath(), _maConfig.GetUriChaine()); if (string.IsNullOrEmpty(resteChemin)) { VariablesGlobales._leLog.LogCustom("Vous ne pouvez supprimer le répertoire racinne !"); MessageBox.Show("Vous ne pouvez supprimer le répertoire racinne !"); } else { if (transfer.EstUnDossier()) { _monFtp.DeleteFolder(resteChemin); } else { _monFtp.DeleteFile(resteChemin); } } _monFtp.Close(); } }
/// <summary> /// Deletes a directory from FTP /// </summary> /// <param name="opts">The options</param> /// <returns>The result</returns> int FTPDeleteDirectory(FTPDeleteDirectoryOptions opts) { using (Ftp ftp = new Ftp()) { try { ftp.Connect(Properties.Settings.Default.FTPServer); ftp.Login(Properties.Settings.Default.FTPUsername, CommandLineSecurity.ToInsecureString(CommandLineSecurity.DecryptString(Properties.Settings.Default.FTPPassword))); } catch (Exception ex) { MessageBox.Show(new Form(), ex.Message, "Mist of Time Publisher", MessageBoxButtons.OK, MessageBoxIcon.Error); return(1); } try { if (!ftp.FolderExists("cdn")) { ftp.CreateFolder("cdn"); } } catch (Exception ex) { MessageBox.Show(new Form(), ex.Message, "Mist of Time Publisher", MessageBoxButtons.OK, MessageBoxIcon.Error); return(1); } try { if (!opts.ServerPath.StartsWith("/")) { opts.ServerPath = "/" + opts.ServerPath; } ftp.DeleteFolder("cdn" + opts.ServerPath); } catch (Exception) { return(2); } } return(0); }