Click here to Skip to main content
15,887,886 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
C#
// Create a FTPCredentials
FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create(strFTPServer + "/" + strRemoteDirectory + "/");
ftpRequest.Credentials = new NetworkCredential(strFTPUser, strFTPPassword);
ftpRequest.Method = WebRequestMethods.Ftp.ListDirectory;


// Associate the new Uri object to the myProxy object.
WebProxy myProxy = new WebProxy();                 
Uri newUri = new Uri(strProxyAddress);               
myProxy.Address = newUri;


// Create a NetworkCredential object.
myProxy.Credentials = new NetworkCredential(strUserName, strPassword);
ftpRequest.Proxy = myProxy;


//DownLoad  file
ftpRequest.Method = WebRequestMethods.Ftp.DownloadFile;
FtpWebResponse response = (FtpWebResponse)ftpRequest.GetResponse();
StreamReader streamReader = new StreamReader(response.GetResponseStream());


MemoryStream memStream = new MemoryStream();
List<string> directories = new List<string>();


string line = streamReader.ReadLine();
while (!string.IsNullOrEmpty(line))
{
    directories.Add(line);
    line = streamReader.ReadLine();
}
Posted
Updated 10-Aug-14 22:17pm
v2
Comments
Richard MacCutchan 8-Aug-14 8:37am    
You are calling ReadLine each time. Use a method that reads more data.
George Jonsson 11-Aug-14 4:19am    
What is the actual question?

1 solution

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900