資源簡介
c#實現 ftp ;http;共享方式下載文件.cs
代碼片段和文件信息
//從ftp服務器上下載文件的功能??
????????public?void?Download(string?ftpServerIP?string?ftpUserID?string?ftpPassword?string?fileName?string?Destination)??
????????{??
????????????FtpWebRequest?reqFTP;??
????????????try??
????????????{??
????????????????FileStream?outputStream?=?new?FileStream(Destination?+?“\\“?+?fileName?FileMode.Create);??
????????????????//?根據uri創建FtpWebRequest對象???
????????????????reqFTP?=?(FtpWebRequest)FtpWebRequest.Create(new?Uri(“ftp://“?+?ftpServerIP?+?“/“?+?fileName));??
????????????????//?指定執行什么命令??
????????????????reqFTP.Method?=?WebRequestMethods.Ftp.DownloadFile;??
????????????????//?默認為true,連接不會被關閉??
????????????????reqFTP.UseBinary?=?true;??
????????????????//?ftp用戶名和密碼??
????????????????reqFTP.Credentials?=?new?NetworkCredential(ftpUserID?ftpPassword);??
????????????????FtpWebResponse?ftpresponse?=?(FtpWebResponse)reqFTP.GetResponse();??
????????????????Stream?ftpStream?=?ftpresponse.GetResponseStream();??
????????????????long?cl?=?ftprespo
?屬性????????????大小?????日期????時間???名稱
-----------?---------??----------?-----??----
?????文件???????4941??2020-03-06?14:29??c#實現?ftp?;http;共享方式下載文件.cs
-----------?---------??----------?-----??----
?????????????????4941????????????????????1
評論
共有 條評論