0
Good afternoon, everyone,
I need to extract the files that are in the FTP folders. Following the examples that are in these links:
Ftpwebresponse.Getresponsestream returning an HTML
I was able to extract the name of the FTP folders but now I need to know how to extract the files that are saved in those folders.
Can someone help me ?
Follow the code I’m using, which can be found in one of the links mentioned 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();
}
}
}
What does "extract" mean? Download? Or unzip?
– Jéf Bueno
@jbueno, when I say extract, I mean to download the files that are in the ftp folders.
– Diego Farias
@jbueno, I managed to solve, I will post the code as an answer there in case someone needs, already has a basis for consultation.
– Diego Farias