inet下载的问题
我的ftp服务器就在局域网内。
只下载一个文件,调试的时候,有时候好好的,但是经常cpu占用到了98%,99%,文件一直显示是0字节。请大家帮忙看看是什么原因?我贴代码。
Friend Sub execute(ByVal RemoteFile As String, ByVal LocalFile As String, ByVal FtpCommand As String)
Dim strIpAddr As String, strUser As String, strPass As String
strIpAddr = "ftp://192.168.1.210"
strUser = "ranassa"
strPass = "871116"
With Inet1
.Protocol = icFTP
.RequestTimeout = 60
.RemotePort = 21
.AccessType = icDirect
.URL = strIpAddr
.UserName = strUser
.Password = strPass
End With
Select Case LCase(FtpCommand)
Case "put"
Inet1.execute , FtpCommand & " " & Chr(34) & LocalFile & Chr(34) & " " & Chr(34) & RemoteFile & Chr(34)
Case "get"
If Dir(LocalFile, vbNormal) <> "" Then Kill LocalFile
Inet1.execute , FtpCommand & " " & Chr(34) & RemoteFile & Chr(34) & " " & Chr(34) & LocalFile & Chr(34)
End Select
Do While Inet1.StillExecuting
DoEvents
Loop
Inet1.execute , "close"
Inet1.execute , "quit"
End Sub
[解决办法]
用inet不好,经常会卡住,推荐使用bkDLControl来下载文件,这个控件自带进度条的。
去Google一下“bkDLControl”就一大堆,祝你好运