回复 2# geshenggang4 #include <FTPEx.au3>
#include "CoProc.au3"
While 1
$iPidotherfuc = _CoProc("ftp")
Sleep(10000)
WEnd
Func ftp()
Dim $downftpfileflag
Dim $fFailIfExists
$server = '172.21.16.46'
$username = 'wwxsawis'
$pass = 'awis123'
$Open = _FTP_Open('SlipFinder ftp ')
$Conn = _FTP_Connect($Open, $server, $username, $pass)
$aFile = _FTP_ListToArray($Conn, 2) ;只找文件
If IsArray($aFile) Then
Sleep(2000) ;等待下,以防止机台产生数据中
For $i= 1 To $aFile[0]
$filegroup=StringSplit($aFile[$i],".")
;MsgBox(0,"",$filegroup[2])
If $filegroup[2] = "txt" Then ;如果是txt档,则下载此文件
$downftpfileflag=_FTP_FileGet($Conn,"/" & $aFile[$i] ,"C:" & $aFile[$i], $fFailIfExists = False) ;false为不覆盖
MsgBox(0,"上传标志",$downftpfileflag ,1)
If $downftpfileflag = 1 Then ;判断是否下载成功,成功即可删除
_FTP_FileDelete($Conn, "/" & $aFile[$i])
MsgBox(0,"文件夹名",$filegroup[1])
_FTP_DirDelete($Conn, "/" & $filegroup[1])
MsgBox(0,"","上传后删除啦",1)
Else ;如果下载不成功,
;MsgBox(0,"@error",@error,1)
$downftpfileflag=_FTP_FileGet($Conn,"/" & $aFile[$i] ,"C:" & $aFile[$i], $fFailIfExists = False)
EndIf
Else ;如果不是txt档,则直接删除
_FTP_FileDelete($Conn, "/" & $aFile[$i])
MsgBox(0,"","直接删除啦",1)
EndIf
Next
EndIf
$Ftpc = _FTP_Close($Open)
EndFunc
|