免费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(); } } }
到此这篇关于 .NET Framework 的项目如何使用 FTP 下载文件的文章就介绍到这了,更多相关FTP 服务器下载文件内容请搜索脚本之家以前的文章或继续浏览下面的相关文章希望大家以后多多支持脚本之家!
来源链接:https://www.jb51.net/aspnet/311008i7c.htm
© 版权声明
本站所有资源来自于网络,仅供学习与参考,请勿用于商业用途,否则产生的一切后果将由您(转载者)自己承担!
如有侵犯您的版权,请及时联系3500663466#qq.com(#换@),我们将第一时间删除本站数据。
如有侵犯您的版权,请及时联系3500663466#qq.com(#换@),我们将第一时间删除本站数据。
THE END
暂无评论内容