在使用Inet時,如何得知下載的網頁或ftp時的檔案下載進度。
http://www.vbqa.com/discuss/read.asp?id=7163 http://www.vbqa.com/discuss/read.asp?id=6560 或全文搜尋 "Inet"
若要知道流程用inet.Execute "http://URL/", "GET"比較好 再用inet.GetHeader("Content-length")來得到下載檔案的大小, 然後從vtData的資料來計算已下載的部分,便可計算進度,ftp我還沒試過, 我只抓過網頁上的檔案,以下是做法(取自MSDN2000jan) Private Sub Inet1_StateChanged(ByVal State As Integer) Dim vtData As Variant ' Data variable. Select Case State ' ... Other cases not shown. Case icResponseCompleted ' 12 ' Open a file to write to. Open txtOperation For Binary Access _ Write As #intFile ' Get the first chunk. NOTE: specify a Byte ' array (icByteArray) to retrieve a binary file. vtData = Inet1.GetChunk(1024, icString) Do While LenB(vtData) > 0 Put #intFile, , vtData ' Get next chunk. vtData = Inet1.GetChunk(1024, icString) Loop Put #intFile, , vtData Close #intFile End Select End Sub