当前位置:首页 » 文件管理 » vb登录ftp

vb登录ftp

发布时间: 2024-08-03 04:07:00

① vb中怎么应用ftp

对于FTP,你可以使用Execute方法执腊扰行FTP命令SIZE获得文件大小。然后在StateChanged事件中可以获得返回的文件大小。
Private Sub Command1_Click()
Inet1.Execute "ftp://127.0.0.1", "SIZE 1.gif"
End Sub

Private Sub Inet1_StateChanged(ByVal State As Integer)
'State = 12 时,用 GetChunk 方法检索服务器的响应。

Dim vtData As Variant ' Data variable.
Select Case State
'掘岁...没有列举其它情况。
Case icError '11
'出现错误时,返回 ResponseCode 和 ResponseInfo。
vtData = Inet1.ResponseCode & ":" & _
Inet1.ResponseInfo
Case icResponseCompleted ' 12

Dim strData As String
Dim bDone As Boolean: bDone = False

'取得第一个块。
vtData = Inet1.GetChunk(1024, icString)
DoEvents

Do While Not bDone
strData = strData & vtData
'取得下一个块。
vtData = Inet1.GetChunk(1024, icString)
DoEvents

If Len(vtData) = 0 Then
bDone = True
End If
Loop
MsgBox strData
End Select

End Sub

对于HTTP下载,你判局睁可以用GetHeader(Content-length)来获得文件大小。但不是所有HTTP下载时都能获得文件长度,特别是通过代理服务器下载文件时。如:
Private Sub Form_Load()
Inet1.Execute "http://askpro.yeah.net/"
End Sub

Private Sub Inet1_StateChanged(ByVal State As Integer)
If State = icResponseReceived Then
MsgBox "File size is " & Inet1.GetHeader("Content-Length")
End If
End Sub

② VB中怎么写,打开之后就进入一个FTP,自动输入密码。读取到FTP上的文件

添加一个部件“Microsoft Internet Transfer Control”然后在窗体上添加一个此对象“Inet1”,设置属性Protocol:2-icFTPRemoteHost:你的FTP服务器IPUsername:你的用户名Password:你的密码 然后再用相关FTP命令读取服务器中的文件.

③ VB阈炬帴鍒癴tp锛屽苟浼犻佹枃浠讹纴镊锷ㄨ嗙洊铡熸湁鏂囦欢

璇峰弬钥,閲囩撼!璋㈣阿!

1,鍒╃敤Inet鎺т欢涓娄紶鏂囦欢

镙煎纺: Inet1.Execute , "put 链鍦版枃浠 杩灭▼鏂囦欢"

锣冧緥:

'鍒濆嫔寲Inet鎺т欢
Inet1.Protocol = icFTP
Inet1.url = "ftp://u0501901.k1.13939.org"
Inet1.RemotePort = 21
Inet1.UserName = "u0501901"
Inet1.Password = "750531179574"

label3.Caption = "姝e湪涓娄紶....."

'鍏埚叧闂褰揿墠镄勬暟鎹搴揿瓨杩炴帴
cn.Close

Inet1.Execute , "put" & " " & App.Path & "\vbhelp.mdb" & " " & "/vbhelp/vbhelp.mdb"

Do While Inet1.StillExecuting
DoEvents
Loop
label3.Caption = "涓娄紶鎴愬姛"

'閲嶆柊杩炴帴鏁版嵁搴
dbconnect

2 ?鍒╃敤Inet鎺т欢涓嬭浇鏂囦欢

镙煎纺锛 inet1.execute , "get 杩灭▼鏂囦欢 链鍦版枃浠"锛屾敞镒忕┖镙

'鍒濆嫔寲INET1鎺т欢
Inet1.Protocol = icFTP
Inet1.url = "ftp://u0501901.k1.13939.org"
Inet1.RemotePort = 21
Inet1.UserName = "u0501901"
Inet1.Password = "750531179574"

label3.Caption = "姝e湪涓嬭浇...."

'镙煎纺锛 inet1.execute , "get 杩灭▼鏂囦欢 链鍦版枃浠"锛屾敞镒忕┖镙
Inet1.Cancel
Inet1.Execute , "GET /vbhelp/vbhelp.mdb c:\temp\vbhelp.mdb"
Do While Inet1.StillExecuting
DoEvents
Loop

label3.Caption = "涓嬭浇鎴愬姛"

3 ?鍒╃敤INET鎺т欢寤虹珛杩灭▼镄勬枃浠跺す

Inet1.AccessType = icUseDefault
Inet1.RemotePort = 21
Inet1.Protocol = icFTP
Inet1.url = "u0711084.k1.13939.org"
Inet1.UserName = "u0711084"
Inet1.Password = "750531179574"

Inet1.Execute , "mkdir vbtest"
Do While Inet1.StillExecuting
DoEvents
Loop

Inet1.Execute , "close"
Inet1.Execute , "quit"
MsgBox "鎴愬姛寤虹珛鏂囦欢澶"

4 ?鍒╃敤INET鎺т欢鍒犻櫎杩灭▼鏂囦欢澶

鏂规硶璺熷缓绔嬫枃浠跺す涓镙凤纴鍒犻櫎锻戒护涓簉mdir锛屼絾鍙鑳藉垹闄ょ┖鐩褰曪纴鍒犻櫎鏂囦欢鐢╠elete

④ VB镓句竴娈礔TP浠g爜瀹炵幇

鐢╒B浠g爜瀹炵幇瀵笷TP镄勪笂浼犲拰涓嬭浇.鍦ㄧ绣涓婃垒鍒颁简涓鏂规硶.
杩欎釜鏂规硶鏄鐢↖NTERNET浼犺緭鎺т欢𨱒ュ疄鐜扮殑.
娣诲姞浜咺NTERNET浼犺緭鎺т欢钖嵘B浠g爜濡备笅"
'鍒濆嫔寲鎺т欢镄勫睘镐:
With Inet1
.URL = "ftp://192.168.0.50"
.UserName = "user"
.Password = "123"
.Protocol = icFTP
.RequestTimeout = 120
End With
,鍦‵TP镙圭洰褰曚笅鍒涘缓鏂囦欢澶笕bc
Call Inet1.Execute(, "mkdir abc")
,鍦‵TP镙圭洰褰曚笅杞123.txt鍒瘅鐩
Call Inet1.Execute(, "get 123.txt d:\123.txt")
'鎶奷:\123.txt涓娄紶鍒癋TP镙圭洰褰
Call Inet1.Execute(, "put d:\123.txt 123.txt")
'鎶奷:\123.txt涓娄紶鍒癋TP镙圭洰褰
Call Inet1.Execute(, "send d:\123.bmp")

热点内容
php解压程序 发布:2025-01-15 17:06:22 浏览:140
刷助力脚本 发布:2025-01-15 17:02:31 浏览:519
c盘里的用户文件夹可以删除 发布:2025-01-15 16:56:45 浏览:949
虚幻4编译到哪里 发布:2025-01-15 16:50:19 浏览:754
透明度渐变android 发布:2025-01-15 16:45:08 浏览:834
dos连接oracle数据库 发布:2025-01-15 16:41:39 浏览:904
网络配置比较低怎么做 发布:2025-01-15 16:35:38 浏览:361
android弹出键盘监听 发布:2025-01-15 16:35:11 浏览:207
uz画图编程 发布:2025-01-15 16:32:44 浏览:883
ppt怎么解压 发布:2025-01-15 16:14:58 浏览:849