1

I use the AsyncRead methode (UserControl.AsyncRead Path, FileType, Key, DownloadType) in VB6 to download a file from internet. Everything works fine except am AsyncReadProgress when the internet goes down while a file is downloading.

The AsyncReadProgress event works the whole time because I can get the AsyncProp.StatusCode. But when the network goes down the AsucnReadProgress event won't fire.

Public Sub Download(URL As String, sDestination As String, Optional sId As String = "Id")
    colDest.Add sDestination, sId
    UserControl.AsyncRead URL, vbAsyncTypeFile, sId, vbAsyncReadForceUpdate
End Sub

Private Sub UserControl_AsyncReadProgress(AsyncProp As AsyncProperty)
    RaiseEvent Progress(AsyncProp.BytesRead, AsyncProp.BytesMax, AsyncProp.PropertyName)
End Sub

Private Sub UserControl_AsyncReadComplete(AsyncProp As AsyncProperty)
    On Error Resume Next

    If AsyncProp.BytesRead > 0 And AsyncProp.BytesRead = AsyncProp.BytesMax Then
        Name AsyncProp.value As colDest.Item(AsyncProp.PropertyName)
    End If

    colDest.Remove AsyncProp.PropertyName
    RaiseEvent Completed(AsyncProp.BytesRead, AsyncProp.BytesMax, AsyncProp.PropertyName)
End Sub

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.