VB程序员的FTP编程指南1.4-下载或上传文件

Visual Basic 专栏收录该内容
8 篇文章 0 订阅

 

专 题:下载或上传文件
主 讲:
qianqian


下载

用ftp下载文件简单而直接。在下载之前,请保证你是在二进制模式下。ftp有两种文件传输模式,ASCII模式和二进制模式。为了转换到二进制模式,可以使用BIN命令。

ftp> bin
200 Type set to I.

返回ASCII模式,请使用ASC命令。

GET命令用来获取文件。如果你想在默认目录使用原始文件名下载文件,你要输入GET <filename> <回车>. 见图4。

你可以只输入GET,系统会提示你要下载的文件名,然后提示你存储到的新文件名(及目录)。


图 4 Get命令

ftp> get readme.txt
200 PORT command successful.
150 Opening BINARY mode data connection for readme.txt(1571 bytes).
226 Transfer complete.
1571 bytes received in 3.46 seconds (0.45 Kbytes/sec)

上传

你可以使用SEND命令上传文件。当然服务器要允许你上传文件才行。如图5。


图 5 SEND命令发送文件.

ftp> send
(local-file) myfile.zip
(remote-file) myfile.zip
200 PORT command successful.
150 Opening BINARY mode data connection for myfile.zip.
226 Transfer complete.
3018 bytes sent in 0.06 seconds (50.30 Kbytes/sec)

(千千VB站整理 转载请保留此信息)

 

  • 0
    点赞
  • 0
    评论
  • 0
    收藏
  • 一键三连
    一键三连
  • 扫一扫,分享海报

相关推荐
'模板: Option Explicit Public Declare Function InternetOpen Lib "wininet.dll" Alias "InternetOpenA" _ (ByVal sAgent As String, ByVal LAccessType As Long, ByVal sProxyName As String, _ ByVal SProxyBypass As String, ByVal lFlags As Long) As Long Public Declare Function InternetConnect Lib "wininet.dll" Alias "InternetConnectA" _ (ByVal hInternetSession As Long, ByVal sServerName As String, _ ByVal nServerPort As Integer, ByVal sUsername As String, _ ByVal sPassword As String, ByVal lService As Long, _ ByVal lFlags As Long, ByVal lContext As Long) As Long Public Declare Function FtpGetFile Lib "wininet.dll" Alias "FtpGetFileA" _ (ByVal hFtpSession As Long, ByVal lpszRemoteFile As String, _ ByVal lpszNewFile As String, ByVal fFailIfExists As Boolean, _ ByVal dwFlagsAndAttributes As Long, ByVal dwFlags As Long, _ ByVal dwContext As Long) As Boolean Public Declare Function FtpPutFile Lib "wininet.dll" Alias "FtpPutFileA" _ (ByVal hFtpSession As Long, ByVal lpszLocalFile As String, _ ByVal lpszRemoteFile As String, ByVal dwFlags As Long, _ ByVal dwContext As Long) As Boolean Public Declare Function FtpDeleteFile Lib "wininet.dll" Alias "FtpDeleteFileA" _ (ByVal hFtpSession As Long, ByVal lpszFileName As String) As Boolean Public Declare Function FtpRenameFile Lib "wininet.dll" Alias "FtpRenameFileA" _ (ByVal hFtpSession As Long, ByVal lpszExsiting As String, ByVal lpszNew As String) As Boolean Public Declare Function InternetCloseHandle Lib "wininet.dll" (ByVal hInet As Long) As Integer Public Declare Function FtpFindFirstFile Lib "wininet.dll" Alias "FtpFindFirstFileA" _ (ByVal hFtpSession As Long, ByVal lpszSearchFile As String, _ lpFindFileData As WIN32_FIND_DATA, ByVal dwFlags As Long, _ ByVal dwContent As Long) As Long Public Declare Function InternetFindNextFile Lib "wininet.dll" Alias "InternetFindNextFileA" _ (ByVal hFind As Long, lpvFndData As WIN32_FIND_DATA) As Long Public Type FILETIME dwLowDateTime As Long dwHighDateTime As L
©️2020 CSDN 皮肤主题: 大白 设计师:CSDN官方博客 返回首页
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、C币套餐、付费专栏及课程。

余额充值