// Collection of code snippets by Arne Vajhøj // (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) using System; using System.IO; using System.Net; namespace E { public class Program { public static string ListRaw(string url) { FtpWebRequest req = (FtpWebRequest)WebRequest.Create(url); req.Method = WebRequestMethods.Ftp.ListDirectoryDetails; using(FtpWebResponse resp = (FtpWebResponse)req.GetResponse()) { using(StreamReader sr = new StreamReader(resp.GetResponseStream())) { return sr.ReadToEnd(); } } } public static string ListRaw(string url, string un, string pw) { FtpWebRequest req = (FtpWebRequest)WebRequest.Create(url); req.Credentials = new NetworkCredential(un, pw); req.Method = WebRequestMethods.Ftp.ListDirectoryDetails; using(FtpWebResponse resp = (FtpWebResponse)req.GetResponse()) { using(StreamReader sr = new StreamReader(resp.GetResponseStream())) { return sr.ReadToEnd(); } } } public static void Main(string[] args) { Console.WriteLine(ListRaw("ftp://arne:xxxxxx@arne/")); Console.WriteLine(ListRaw("ftp://arne/", "arne", "xxxxxx")); } } }