المساعد الشخصي الرقمي

مشاهدة النسخة كاملة : FTP Problem



C# Programming
06-17-2011, 07:21 AM
I have this FTP code. I'm trying to get a list of files from the server. All it returns is an entry for the root folder.. Using FileZilla and/or CuteFTP I can see the subfolders and files in them. Why isnt't my returning anything other than the root folder?

public struct FTPCredentials{ public string FTPServer { get; set; } public string UserName { get; set; } public string Password { get; set; }} public List GetFileList(FTPCredentials Credentials){ List retVal = new List(); FtpWebRequest request = (FtpWebRequest)WebRequest.Create(Credentials.FTPServer); request.Method = WebRequestMethods.Ftp.ListDirectoryDetails; request.KeepAlive = true; request.UsePassive = false; try { request.Credentials = new NetworkCredential(Credentials.UserName, Credentials.Password); FtpWebResponse response = (FtpWebResponse)request.GetResponse(); Stream stream = response.GetResponseStream(); StreamReader reader = new StreamReader(stream); string line = reader.ReadLine(); while (!string.IsNullOrEmpty(line)) { retVal.Add(line); line = reader.ReadLine(); } reader.Close(); response.Close(); } catch (Exception e) { throw e; } return retVal;}Everything makes sense in someone's mind