Jump to content

InetGet correct way of checking error during downloading a file


Recommended Posts

I am using this code to Download a file 
I don't know correct way of checking error during downloading

Global $DownloadStatus = InetGet($url, $fileName, Default, $INET_DOWNLOADBACKGROUND)

While 1
    $ArrayOFDownloadStatuts = InetGetInfo($DownloadStatus)
    If Not $ArrayOFDownloadStatuts[4] = 0 Then
            MsgBox(0,"Error","Error During Downloading")
            ExitLoop
    EndIf
    If $ArrayOFDownloadStatuts[2] Then
            MsgBox(0,"","Compelted")
            ExitLoop
    EndIf
WEnd

I am using that code but don't know why it gives error during downloading the file 

is it wrong way of checking error or is there network error on my pc ? :P 
thank you :D 

Link to comment
Share on other sites

From help file:   fifth element (at index 4) - The error value for the download. The value itself is arbitrary. Testing that the value is non-zero is sufficient for determining if an error occurred - so I assume that if that element has value of zero than there is no error. You could also do something like this:

$ArrayOFDownloadStatuts = InetGetInfo($DownloadStatus)
If @error Then
;do something
EndIf
Link to comment
Share on other sites

  • 1 year later...

$ArrayOFDownloadStatuts = InetGetInfo($hDownload)
        If $ArrayOFDownloadStatuts[3] = True Then
          MsgBox (0,"", "OK")
        Else
          MsgBox (0, "", "not ok")
        EndIf
                       
        InetClose($hDownload)

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
 Share

×
×
  • Create New...