我想问一下怎么使用VB 里面的inet控件进行下载文件是用Execute这个下载,,给出一个代码谢谢,

解决方案 »

  1.   

    例如,为获得一个文件,下面的代码调用 Execute 方法,该方法包含着操作名 ("GET") 以及此操作所需的两个文件名:Inet1.Execute "FTP://ftp.microsoft.com", _
    "GET Disclaimer.txt C:\Temp\Disclaimer.txt"
      
    *****************************************************************************
    欢迎使用CSDN论坛专用阅读器 : CSDN Reader(附全部源代码) 
    http://feiyun0112.cnblogs.com/
      

  2.   

    Private Sub Command1_Click()
    Dim strURL As String, m_lDocSize As Long, strBuffer As String
    Dim lngArrivedDataSize As Long, strArrivedData As String
    strURL = "http://zhidao.baidu.com/question/68055519.html"
    Inet1.Execute strURL, "GET" '发出请求
    Do While Inet1.StillExecuting '等待请求结束
    DoEvents
    Loop
    If Len(Inet1.GetHeader("Content-Length")) > 0 Then '获取文件头信息
    m_lDocSize = CLng(Inet1.GetHeader("Content-Length"))
    End If
    With ProgressBar1 '初始化进度条
    .Max = m_lDocSize - Len(Inet1.GetHeader)
    .Min = 0
    Do '开始获取数据
    DoEvents
    strBuffer = Inet1.GetChunk(512)
    strArrivedData = strArrivedData & strBuffer
    lngArrivedDataSize = Len(strArrivedData)
    .Value = lngArrivedDataSize '进度显示
    Loop Until Len(strBuffer) = 0
    .Value = .Max
    End With
    Text1.Text = strArrivedData
    MsgBox "下载完毕!"
    End Sub