本帖最后由 xms77 于 2012-11-12 20:54 编辑
回复 3# claud21
给你个我的列子:
#include <FTPEx.au3>
$FTP_Server = IniRead("x:\xms\config.txt", "TSPC_Checker_FTP", "SERVER", "unknow")
$user = IniRead("x:\xms\config.txt", "TSPC_Checker_FTP", "USERNAME", "unknow")
$Password = IniRead("x:\xms\config.txt", "TSPC_Checker_FTP", "PASSWORD", "unknow")
$FilePath = IniRead("x:\xms\config.txt", "TSPC_Checker_FTP", "FILE_PATH", "unknow")
$ret = _DownloadFileFromFTP($FTP_Server, $user, $Password, $FilePath, @ScriptName)
If Not @error Then MsgBox(0,0,"Download success")
Func _DownloadFileFromFTP($iIP, $iUsername, $iPassword, $iFilePath, $iFilename)
Local $Open = _FTP_Open('MyFTP Control')
Local $Conn = _FTP_Connect($Open, $iIP, $iUsername, $iPassword, 0, "21")
If $Conn Then
$File_Get = _FTP_FileGet($Conn, $iFilePath & "\" & $iFilename, @ScriptDir & "\updated.exe")
If Not @error Then
Return 1 ;下载成功
Else
Return SetError(-1, -1, 0) ;下载失败
EndIf
_FTP_Close($Conn)
Else
Return SetError(-1, -1, -1) ;FTP连接失败,返回值为-1,并设置Error为-1
EndIf
EndFunc ;==>_DownloadFileFromFTP
|