免费FTP客户端 Cyberduck for Windows v8.7.1.4077 免费安装版
FTP客户端工具 SmartFTP v10.0.3169 64bit 官方最新安装版
FTP客户端工具 FTPRush V3.5.6 绿色多语版
此示例演示如何从 FTP 服务器下载文件。
本文专门针对面向 .NET Framework 的项目。 对于面向 .NET 6 及更高版本的项目,不再支持 FTP。
C#
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/test.htm"); request.Method = WebRequestMethods.Ftp.DownloadFile; // 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($"Download Complete, status {response.StatusDescription}"); reader.Close(); response.Close(); } } }
声明:本站所有文章,如无特殊说明或标注,均为本站原创发布。任何个人或组织,在未征得本站同意时,禁止复制、盗用、采集、发布本站内容到任何网站、书籍等各类媒体平台。如若本站内容侵犯了原著者的合法权益,可联系我们进行处理。
评论(0)