.NET?Framework?的項目如何使用?FTP?下載文件
免費(fèi)FTP客戶端 Cyberduck for Windows v8.7.1.4077 免費(fèi)安裝版
FTP客戶端工具 SmartFTP v10.0.3169 64bit 官方最新安裝版
此示例演示如何從 FTP 服務(wù)器下載文件。
本文專門針對面向 .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(); } } }
到此這篇關(guān)于 .NET Framework 的項目如何使用 FTP 下載文件的文章就介紹到這了,更多相關(guān)FTP 服務(wù)器下載文件內(nèi)容請搜索腳本之家以前的文章或繼續(xù)瀏覽下面的相關(guān)文章希望大家以后多多支持腳本之家!
相關(guān)文章
解決VS2012 Express的There was a problem sending the command to
安裝Visual Studio 2012 Express之后,雙擊打開web.config文件時經(jīng)常出現(xiàn)“There was a problem sending the command to the program”的錯誤,然后VS2012 Express打開了,但web.config文件沒打開,需要再次雙擊web.config文件才能打開。很是煩人2013-02-02EF?Core項目中不同數(shù)據(jù)庫需要的安裝包介紹
這篇文章介紹了EF?Core項目中不同數(shù)據(jù)庫需要的安裝包,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧2022-05-05asp.net uploadify實現(xiàn)多附件上傳功能
這篇文章主要為大家詳細(xì)介紹了asp.net uploadify實現(xiàn)多附件上傳功能,具有一定的參考價值,感興趣的小伙伴們可以參考一下2016-11-11