Good afternoon guys,
I need to extract the files that are in the FTP folders. Following the examples that are in these links:
p>FtpWebResponse.GetResponseStream returning an HTML
I managed to extract the name of the FTP folders, but now I need to know how to extract the files that are saved in these folders.
Can anyone help me?
Here is the code I'm using, which can be found in one of the links quoted above.
Thank you.
public static void BUSCADIRTESTE(string uri, string usuario, string senha)
{
FtpWebRequest ftpRequest = (FtpWebRequest)WebRequest.Create(uri);
ftpRequest.Credentials = new NetworkCredential(usuario, senha);
ftpRequest.Method = WebRequestMethods.Ftp.ListDirectory;
FtpWebResponse response = (FtpWebResponse)ftpRequest.GetResponse();
using (StreamReader streamReader = new StreamReader(response.GetResponseStream()))
{
List<string> directories = new List<string>();
string line = streamReader.ReadLine();
while (!string.IsNullOrEmpty(line))
{
directories.Add(line);
line = streamReader.ReadLine();
}
}
}