FTP로 디렉터리 내용 나열

홈 > 공유팁! > 프로그램 관련
프로그램 관련

FTP로 디렉터리 내용 나열

꽁스짱 0 856

using System; using System.IO; using System.Net; namespace Examples.System.Net { public class WebRequestGetExample { public static void Main () { // Get the object used to communicate with the server. FtpWebRequest request = (FtpWebRequest)WebRequest.Create("ftp://www.contoso.com/"); request.Method = WebRequestMethods.Ftp.ListDirectoryDetails; // This example assumes the FTP site uses anonymous logon. request.Credentials = new NetworkCredential ("anonymous","janeDoe@contoso.com"); 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(); } } } 



0 Comments
제목