.NET ez 2012-08-24
本篇利用 FtpWebRequest 下載 FTP 檔案:
private static string FtpDownLoad(string url, string strUserName, string strPassword) { FtpWebRequest request = (FtpWebRequest)WebRequest.Create(new Uri(url)); request.Method = WebRequestMethods.Ftp.DownloadFile; if (!String.IsNullOrEmpty(strUserName) && !String.IsNullOrEmpty(strPassword)) request.Credentials = new NetworkCredential(strUserName, strPassword); FtpWebResponse response = (FtpWebResponse)request.GetResponse(); Stream responseStream = response.GetResponseStream(); StreamReader reader = new StreamReader(responseStream, Encoding.Default); return reader.ReadToEnd(); }
標籤: .NET
本文章網址:
https://www.ez2o.com/Blog/Post/csharp-FTP-Download-File-Sample-Code
https://www.ez2o.com/Blog/Post/281
https://www.ez2o.com/Blog/Post/csharp-FTP-Download-File-Sample-Code
https://www.ez2o.com/Blog/Post/281