I\'m trying to retrieve a list of files from an FTP server, but I\'m getting some weird non-ASCII responses.
Here is the code that I am using:
pub
For what it's worth, the System.Net namespace has the FtpWebRequest and FtpWebResponse classes beginning in .Net 2.0.
Here's some code I've used that writes the server's files to a local file:
...
FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create(address);
ftpRequest.Credentials = new NetworkCredential(username, password);
ftpRequest.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
ftpRequest.KeepAlive = false;
FtpWebResponse ftpResponse = (FtpWebResponse)ftpRequest.GetResponse();
sr = new StreamReader(ftpResponse.GetResponseStream());
sw = new StreamWriter(new FileStream(fileName, FileMode.Create));
sw.WriteLine(sr.ReadToEnd());
sw.Close();
ftpResponse.Close();
sr.Close();
...