Sign in to follow this  
Followers 0
Nubie

how can make FTP_ProgressDownload work mult-times

4 posts in this topic

I'm trying make FTP downloader my list files. but it only work well on first file then it stop. What wrong with me. Please help !

#include <FTPEx.au3>
#include <File.au3>
$file2 = @ScriptDir & "\file_download.txt"
Local $sServer = 'ftp.mysite.com'
Local $sUsername = 'user'
Local $sPass = 'pass'

If FileExists($file2) Then
    ProgressOn("Verify & Update", "Downloading", "Working")
    Local $iCountLines2 = _FileCountLines($file2)
    Local $hInternetSession = _FTP_Open('MyFTP')
    Local $hFTPSession = _FTP_Connect($hInternetSession, $sServer, $sUsername, $sPass, 1)
    for $b=1 to $iCountLines2
        Local $sFileRead2 = FileReadLine($file2, $b)
        MsgBox(0,"",$sFileRead2)
        _FTP_ProgressDownload($hFTPSession, @ScriptDir & $sFileRead2, $sFileRead2)
        $count_do2 = $b *100 / $iCountLines2
        ProgressSet($count_do2, Round($count_do2) & "%")
    next
    _FTP_Close($hInternetSession)
    FileDelete($file2)
EndIf
ProgressSet(100, "Done!")
Sleep(750)
ProgressOff()
Exit

Share this post


Link to post
Share on other sites



I haven't tested this theory, but it seems to me that you need to move your _FTP_ProgressDownload line to right before the For...Next loop. I think on each loop, you are creating a new version of it and the ProgressSet is not setting the percentage on topmost one.


RAID Calculator | Software Installer

The truth has been suppressed since the dawn of time.

Share this post


Link to post
Share on other sites

You should better use _FTP_FileGet, much easier

    for $b=1 to $iCountLines2
        Local $sFileRead2 = FileReadLine($file2, $b)
       ; MsgBox(0,"",$sFileRead2)
        _FTP_FileGet($hFTPSession, $sFileRead2, @ScriptDir & "\" & $sFileRead2)
        $count_do2 = $b *100 / $iCountLines2
        ProgressSet($count_do2, Round($count_do2) & "%")
        ; Sleep(1000)
    next

:)

Share this post


Link to post
Share on other sites

Thanks mikell ! I know _FTP_FileGet. Here's my way was worked before.

If FileExists($file2) Then
    ProgressOn("Verify & Update", "Download", "Starting...")
    $iCountLines2 = _FileCountLines($file2)
    $hInternetSession = _FTP_Open('XYZ Updater')
    $hFTPSession = _FTP_Connect($hInternetSession, $sServer, $sUsername, $sPass, 1)
    for $b=1 to $iCountLines2
        $sFileRead2 = FileReadLine($file2, $b)
        $count_do2 = $b *100 / $iCountLines2
        ProgressSet($count_do2, Round($count_do2) & "%")
        _FTP_FileGet($hFTPSession, $sFileRead2, @ScriptDir & $sFileRead2)
    next
    _FTP_Close($hInternetSession)
    FileDelete($file2)
EndIf

But I found _FTP_FileGet and _FTP_ProgressDownload will not work if Path on cilent didn't exist (folders). I don't know is it bug or not

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
Sign in to follow this  
Followers 0