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(); } }
List <ITransfer> IClientFtp.ListFileFolder(string unDossier) { List <FtpItem> lesFtpElements = new List <FtpItem>(); List <ITransfer> lesElements = new List <ITransfer>(); using (Ftp monFtp = new Ftp()) { monFtp.Connect(_maConfig.Host, _maConfig.Port); // or ConnectSSL for SSL monFtp.Login(_maConfig.Login, _maConfig.MotDePass); string resteChemin = MethodesGlobales.GetCheminServerSansRacinne(unDossier, _maConfig.GetUriChaine()); if (!string.IsNullOrEmpty(resteChemin)) { monFtp.ChangeFolder(resteChemin); } lesFtpElements = monFtp.GetList(); monFtp.Close(); } foreach (FtpItem unFtpItem in lesFtpElements) { if (unFtpItem.IsFile) { lesElements.Add(new ElementFile(unFtpItem, Path.Combine(unDossier, unFtpItem.Name))); } } return(lesElements); }
public void CreerDossier(string leNmDossierACreer, ElementFolder leDossierDistant) { using (_monFtp = new Ftp()) { _monFtp.Connect(_maConfig.Host, _maConfig.Port); _monFtp.Login(_maConfig.Login, _maConfig.MotDePass); string resteChemin = MethodesGlobales.GetCheminServerSansRacinne(leDossierDistant.GetPath(), _maConfig.GetUriChaine()); _monFtp.ChangeFolder(resteChemin); _monFtp.CreateFolder(leNmDossierACreer); _monFtp.Close(); } }
public void UploadDossier(ElementFolder dossierLocal, ElementFolder dossierDistant) { using (_monFtp = new Ftp()) { _monFtp.Connect(_maConfig.Host, _maConfig.Port); _monFtp.Login(_maConfig.Login, _maConfig.MotDePass); string resteChemin = MethodesGlobales.GetCheminServerSansRacinne(dossierDistant.GetPath(), _maConfig.GetUriChaine()); _monFtp.CreateFolder(MethodesGlobales.GetCheminDossierUploadSurServeur(resteChemin, dossierLocal.GetName())); LocalSearchOptions uneLocalSearchOption = new LocalSearchOptions("*", true); _monFtp.UploadFiles(MethodesGlobales.GetCheminDossierUploadSurServeur(resteChemin, dossierLocal.GetName()), dossierLocal.GetPath(), uneLocalSearchOption); _monFtp.Close(); } }
public void DownloadDossier(ElementFolder dossierDistant, ElementFolder dossierLocal) { using (_monFtp = new Ftp()) { _monFtp.Connect(_maConfig.Host, _maConfig.Port); _monFtp.Login(_maConfig.Login, _maConfig.MotDePass); string resteChemin = MethodesGlobales.GetCheminServerSansRacinne(dossierDistant.GetPath(), _maConfig.GetUriChaine()); string cheminDossierADowloaded = MethodesGlobales.GetCheminDossierLocalDownload(dossierLocal.GetPath(), dossierDistant.GetName()); Directory.CreateDirectory(cheminDossierADowloaded); _monFtp.DownloadFiles(resteChemin, cheminDossierADowloaded, new RemoteSearchOptions("*", true)); _monFtp.Close(); } }