그러냐

c# ftp 파일&디렉토리 리스트 얻기 본문

c#

c# ftp 파일&디렉토리 리스트 얻기

관절분리 2016. 1. 28. 11:37
반응형

Uri ftpUri = new Uri("ftp://xxx.xxx.xxx.xxx/");


                FtpWebRequest reqFtp = (FtpWebRequest)WebRequest.Create(ftpUri);
                reqFtp.Credentials = new NetworkCredential("ID", "PASS");
                reqFtp.Timeout = 10000;
                reqFtp.Method = WebRequestMethods.Ftp.ListDirectory;


                FtpWebResponse resFtp = (FtpWebResponse)reqFtp.GetResponse();


                StreamReader reader;
                reader = new StreamReader(resFtp.GetResponseStream());



                string strData;
                strData = reader.ReadToEnd();


                string[] filesInDirectory = strData.Split(new string[] { "\r\n" }, StringSplitOptions.RemoveEmptyEntries);

                resFtp.Close();

 

 

출처 : http://blog.daum.net/_blog/BlogTypeView.do?blogid=095QI&articleno=13423477&categoryId=646317&regdt=20090324144555#ajax_history_home

반응형