how to list files in ftp code example
Example: how to list files located in ftp server folder using C#
using System;
using System.IO;
using System.Net;
namespace Examples.System.Net
{
public class WebRequestGetExample
{
public static void Main ()
{
FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/");
request.Method = WebRequestMethods.Ftp.ListDirectoryDetails;
request.Credentials = new NetworkCredential ("anonymous","[email protected]");
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Stream responseStream = response.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
Console.WriteLine(reader.ReadToEnd());
Console.WriteLine($"Directory List Complete, status {response.StatusDescription}");
reader.Close();
response.Close();
}
}
}