public FTPDirectory GetFTPHoleTreeByContentTXT(string path, string username = "", string password = "", FrmMain frmMain = null) { FTPDirectory root = new FTPDirectory(path); if (!path.Equals(rootPath) || getFTPClient().IsConnected == false) { rootPath = path; _username = username; _password = password; if (_username.Equals("")) { _username = "******"; } } if (getFTPClient().IsConnected == false) { return(null); } List <string> content = ReadFile(root, "content.txt"); ConvertContentToFTPFiles(root, content); return(root); }
private List <string> ReadFile(FTPDirectory ftpLy, string fileName) { List <string> inhalt = new List <string>(); Stream ftpStream = getFTPClient().OpenRead(fileName); if ((int)ftpStream.Length == 0) { return(inhalt); } var memoryStream = new MemoryStream(); int bytesRead; byte[] buffer = new byte[16 * 1024]; while ((bytesRead = ftpStream.Read(buffer, 0, buffer.Length)) > 0) { memoryStream.Write(buffer, 0, bytesRead); } memoryStream.Flush(); memoryStream.Position = 0; StreamReader reader = new StreamReader(memoryStream); while (reader.Peek() >= 0) { inhalt.Add(reader.ReadLine()); } ftpStream.Close(); reader.Close(); return(inhalt); }
private void ConvertContentToFTPFiles(FTPDirectory root, List <string> content) { long size = 0; string path = ""; foreach (string line in content) { string[] splitty = line.Split('\t'); if (splitty.Length > 1) { if (long.TryParse(splitty[0].Replace("B", ""), out size)) { path = splitty[1]; if ((path.Contains("content") || path.Contains("apps")) && !path.Contains("content.txt") ) { //Create File root.lstFiles.Add(new FTPFile(path, size)); } } } } }
public static List <FTPFile> CheckLocalFolder(string pathToExe, FTPDirectory rootDir, MainDirectory dirToCheck) { List <FTPFile> filesToSync = new List <FTPFile>(); string acPath = Path.GetDirectoryName(pathToExe); foreach (FTPFile file in rootDir.lstFiles.Where(x => x.getSerie().Equals(dirToCheck.ftpDir.PathOnServer)).ToList()) { if (hasDiff(acPath, file)) { filesToSync.Add(file); } } return(filesToSync); }
public static IEnumerable <FTPDirectory> Descendants(this FTPDirectory root) { var nodes = new Stack <FTPDirectory>(new[] { root }); while (nodes.Any()) { FTPDirectory node = nodes.Pop(); yield return(node); foreach (var n in node.subDirectories) { nodes.Push(n); } } }
private Boolean checkFTPServer(string ftpServer) { try { if (GetFTPHelper().CheckConnection() == false) { return(false); } //Hier eventuell ohne user / Passwort rootDir = GetFTPHelper().GetFTPHoleTreeByContentTXT(txtFTP.Text, "", "", this); return(true); } catch (Exception ex) { WriteLog(ex.Message); return(false); } }
public static List <MainDirectory> checkFolderForMainFolders(FTPDirectory rootDir) { return(rootDir.lstFiles.Select(x => x.getSerie()).Distinct().Select(y => new MainDirectory(new FTPDirectory(y), rootDir)).ToList()); }
public MainDirectory(FTPDirectory dir, FTPDirectory root) { rootFolder = root; ftpDir = dir; ftpFilesAlreadyDone = new List <FTPFile>(); }