Jump to content

Recommended Posts

Posted

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
Posted

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

:)

Posted

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

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
  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...