using System; using System.Collections.Generic; using System.Diagnostics; using System.IO; using System.Net; using System.Xml.Linq; namespace prBrowser.Weblogic { public class FTPHelper { public string currentPath = ""; public string serverPath = ""; public string serverFTPName = "RKFTP"; public string serverFTPPassword = "pryk@2020"; public string ftpDefaultFolder = "browser"; public string DownLoad(string filePath, string fileName, string ftpPath, string ftpUserName, string ftpPassWord) { try { if (!Directory.Exists(filePath)) { Directory.CreateDirectory(filePath); } FileStream outputStream = new FileStream(filePath + fileName, FileMode.Create); FtpWebRequest reqFTP = (FtpWebRequest)WebRequest.Create(new Uri(ftpPath + fileName)); reqFTP.Method = "RETR"; reqFTP.Credentials = new NetworkCredential(ftpUserName, ftpPassWord); reqFTP.UseBinary = true; FtpWebResponse response = (FtpWebResponse)reqFTP.GetResponse(); Stream ftpStream = response.GetResponseStream(); long cl = response.ContentLength; int bufferSize = 2048; byte[] buffer = new byte[bufferSize]; for (int readCount = ftpStream.Read(buffer, 0, bufferSize); readCount > 0; readCount = ftpStream.Read(buffer, 0, bufferSize)) { outputStream.Write(buffer, 0, readCount); } ftpStream.Close(); outputStream.Close(); response.Close(); reqFTP = null; return "0"; } catch (Exception ex) { return ex.Message; } } public string getUpdateList() { string message = "0"; try { string uri = serverPath + ftpDefaultFolder + "/UpdateList/"; FtpWebRequest reqFTP = (FtpWebRequest)WebRequest.Create(new Uri(uri)); reqFTP.Credentials = new NetworkCredential(serverFTPName, serverFTPPassword); reqFTP.Method = "LIST"; WebResponse response = reqFTP.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream()); for (string line = reader.ReadLine(); line != null; line = reader.ReadLine()) { if (!line.Contains("