private List<string> pastasFtp(FTP ftplib) { List<string> lstPastas = new List<string>(); foreach (string d in ftplib.ListDirectories()) { if (d.ToUpper().Substring(d.LastIndexOf(" ") + 1, Math.Min(3, d.Length - 1 - d.LastIndexOf(" "))) == "ANO") { lstPastas.Add(d.ToUpper().Substring(d.LastIndexOf( " ") + 1, d.Length - 1 - d.LastIndexOf(" "))); } } lstPastas.Sort(); return lstPastas; }
private string listar() { int inicioPos; try { ftpCon = new ShowLib.FTP(); ftpCon.Connect(servidor, usuario, senha); if(diretorio != "") ftpCon.ChangeDir(diretorio); } catch (Exception ex) { return ex.Message; } try { foreach (string f in ftpCon.List()) { if(f.Contains("POCKETRT")){ inicioPos = f.IndexOf("POCKETRT"); lstArquivosCarregar.Add(f.Substring(inicioPos, f.Length - inicioPos)); } } } catch (Exception ex) { return ex.Message; } return ""; }