string[] files; files = GetFileList(); foreach (string file in files) { xmlDoc.Load("ftp.Test.com/stats/" + file); XmlNodeList itemNodes = xmlDoc.SelectNodes("//Sport"); } // on reading 1600th xml file i get the Exception like The remote server returned an error: 227 Entering Passive Mode (89,202,213,212,6,32) public string[] GetFileList() { string[] downloadFiles; StringBuilder result = new StringBuilder(); WebResponse response = null; StreamReader reader = null; try { FtpWebRequest reqFTP; reqFTP = (FtpWebRequest)FtpWebRequest.Create(new Uri("ftp://ftp.Test.com/stats/")); reqFTP.UseBinary = true; reqFTP.Credentials = new NetworkCredential("Test", "Test"); reqFTP.Method = WebRequestMethods.Ftp.ListDirectory; reqFTP.Proxy = null; reqFTP.KeepAlive = false; //reqFTP.EnableSsl = true; reqFTP.UsePassive = false; response = reqFTP.GetResponse(); reader = new StreamReader(response.GetResponseStream()); string line = reader.ReadLine(); while (line != null) { result.Append(line); result.Append("\n"); line = reader.ReadLine(); } // to remove the trailing '\n' result.Remove(result.ToString().LastIndexOf('\n'), 1); return result.ToString().Split('\n'); } catch (Exception ex) { if (reader != null) { reader.Close(); } if (response != null) { response.Close(); } downloadFiles = null; return downloadFiles; } }
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)