oFTP.InternetReadFile()

FTPv2.ahk / oFTP

oFTP.InternetReadFile()


Downloads a file (with progress bar)

oFTP.InternetReadFile(RemoteFile, [NewLocalFile, FnProgress])

Parameters

RemoteFile

Path of remote file to download

NewLocalFile

(Optional) Local file name/path (if omitted, defaults to name of remote file, saved to script directory)

FnProgress

(Optional) Name of function to handle progress data (similar to registercallback). If not specified, built in function to show progress is used. (see example)

Return Value

True on success, false otherwise.

Remarks

Use .LastError property to get error data

Related

oFTP.InternetWriteFile()

Example

oFTP.InternetReadFile("RTestFile.zip", "LTestFile.zip", "MyProgressFunction")
MyProgressFunction() {
global oFTP
static init
my := oFTP.File
ntotal := my.BytesTotal
if ( my.TransferComplete )
{
Progress, Off
return 1 , init := 0
}
str_sub := "Time Elapsed - " . Round((my.CurrentTime - my.StartTime)/1000) . " seconds"
if !init
{
str_main := my.LocalName . A_Tab . (my.TransferDownload ? "<-":"->") . A_Tab . my.RemoteName
Progress,M R0-%ntotal% P0,%str_sub%, %str_main% ,FTP Transfer Progress
return 1, init :=1
}
Progress, % my.BytesTransfered
Progress,,%str_sub%
}