网上人说 文件夹有<DIR>标识,但是我遍历没有啊! 求高手帮助
private string[] GetFileList(string path, string WRMethods)//上面的代码示例了如何从ftp服务器上获得文件列表 { string[] downloadFiles; StringBuilder result = new StringBuilder(); List<string> strs = new List<string>(); try { Connect(path); reqFTP.Method = WebRequestMethods.Ftp.ListDirectoryDetails; //reqFTP.Method = WebRequestMethods.Ftp.ListDirectory; WebResponse response = reqFTP.GetResponse(); StreamReader reader = new StreamReader(response.GetResponseStream());//中文文件名 string line = reader.ReadLine(); while (line != null) { //if (line.Contains("<DIR>")) //{ result.Append(line); result.Append("\n"); //} line = reader.ReadLine(); } // to remove the trailing '\n' result.Remove(result.ToString().LastIndexOf('\n'), 1); reader.Close(); response.Close(); return result.ToString().Split('\n'); } catch (Exception ex) { System.Web.HttpContext.Current.Response.Write(ex.Message); downloadFiles = null; return downloadFiles; } }
!