close
在 codeproject 中,找到一個簡單好用的 FTP Client Library,且提供原始碼,如果需要下載
可到下列網址進行下載。
http://www.codeproject.com/KB/IP/FtpClient.aspx
那就來寫個簡單程式,測試一下這個 Ftp Client,在這邊使用的 IDE 是 Visual Basic 2010
Express。
在瀏覽器輸入 http://www.codeproject.com/KB/IP/FtpClient.aspx 後,
點選 Download demo project and source - 42.8 Kb 進行下載(需要有 codeproject 帳號)
下載後,解壓縮檔案完成,到 FtpClient\Demo\bin\Debug 拷貝 FtpClient.dll 到你的專案中
(可自行編譯原始碼產生FtpClient.dll)
在專案中加入參考
選擇 FtpClient.dll,即可使用 FTP Client Library
(也可將FtpClient .vb直接加入專案中,則無需使用上方參考設定 )
測試程式碼
Imports Utilities.FTP
Module Module1
Sub Main()
'FTPclient(主機名稱, 帳號, 密碼)
Dim ftp As FTPclient = New FTPclient("127.0.0.1", "test", "123456")
'下載檔案
'Download(來源檔案,目的檔案)
ftp.Download("1.txt", "c:\1.txt")
'上傳檔案
ftp.Upload("c:\2.txt")
'刪除檔案 Ftp Server 上檔案
ftp.FtpDelete("2.txt")
End Sub
End Module
如果需要一個簡單的 Ftp Server ,可到下方連結進行下載
http://support.3com.com/software/utilities_for_windows_32_bit.htm
參考網站:
全站熱搜