執行結果:
Code:
var request = (FtpWebRequest)WebRequest.Create("FTP URL"); request.Method = WebRequestMethods.Ftp.ListDirectoryDetails; request.Credentials = new NetworkCredential("user", "password"); try { var response = (FtpWebResponse)request.GetResponse(); using (var stream = new StreamReader(response.GetResponseStream())) { var list = stream.ReadToEnd(); Console.WriteLine(list); } } catch (WebException ex) { }