marabunta

Download Function add timeout

2 posts in this topic

#1 ·  Posted (edited)

Hi,

EDIT: done

$FileURL = "http://site.de/file.txt"
$FileName = @TempDir & "\file.txt"
$Downloadtimeout = 60000
$INET_DOWNLOADBACKGROUND = 1
$INET_DOWNLOADCOMPLETE = 2

Func Download($FileURL, $FileName, $Downloadtimeout)
    Local $hDownload = InetGet($FileURL, $FileName, 19, $INET_DOWNLOADBACKGROUND)

    $begin = TimerInit()
    Do
        Sleep(250)
        $fDiff = TimerDiff($begin)
        If ($fDiff > $Downloadtimeout) Then
            InetClose($hDownload)
            ExitLoop
        EndIf
    Until InetGetInfo($hDownload, $INET_DOWNLOADCOMPLETE)
    ; Retrieve details about the download file.
    Local $aData = InetGetInfo($hDownload)
    If @error Then
        FileDelete($FileName)
        Return False ; If an error occurred then return from the function and delete the file.
    EndIf
    InetClose($hDownload)
EndFunc   ;==>Download

Download($FileURL, $FileName, $Downloadtimeout)

 

 

Edited by marabunta

Share this post


Link to post
Share on other sites



$INET_DOWNLOADBACKGROUND = 1

 


small minds discuss people average minds discuss events great minds discuss ideas.... and use AutoIt....

Share this post


Link to post
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