写了一个FTP批量更新函数,发现只要 ftp.Download(sourceFile, destinationFile,
ShowUI)最后一个参数设为false,就只能下载一个文件,而且很慢!而设为ture,弹出进度条方式,就下载很快,并可以批量持续,请问是什么原因?
如何解决?
以下内容为程序代码:
1 Dim ftp As New FTPClient
2 ftp.host = vars("FTP_ip地址")
3 ftp.Account = vars("FTP_账号")
4 ftp.password = vars("FTP_密码")
5 ftp.Port = vars("FTP_端口")
6
7 Functions.AsyncExecute("文件刷新","",ftp)
以下内容为程序代码:
1 Dim dls As List(of String)
2 'ftp 以变量2方式代入,避免重复连接
3 'Dim ftp As New FTPClient
4 'ftp.host = vars("FTP_ip地址")
5 'ftp.Account = vars("FTP_账号")
6 'ftp.password = vars("FTP_密码")
7 'ftp.Port = vars("FTP_端口")
8 dls = args(1).GetDetailList(args(0))
9 Dim locfile As String
10 Dim ftpfile As String
11 Dim locpath As String = ProjectPath & "RemoteFiles\"
12 For Each dl As String In dls
13 If dl.Split("*")(2) = "D" Then
14 'Output.Show(args(0) & "/" & dl.Split("*")(0))
15 Functions.Execute("文件刷新", args(0) & "/" & dl.Split("*")(0),args(1))
16 Else
17 'Output.Show(dl)
18 locfile = locpath & args(0) & "\" & dl.Split("*")(0)
19 locfile = locfile.Replace("/","\")
20 locfile = locfile.Replace("\\","\")
21 ftpfile = args(0) & "/" & dl.Split("*")(0)
22 If FileSys.FileExists(locfile) = False Then
23 'Output.Show(locfile)
24 ' Output.Show(ftpfile)
25 args(1).Download(ftpfile,locfile,True)
26 Else
27 Dim info As new FileInfo(locfile)
28 Dim ftpdate As Date = dl.Split("*")(1)
29 If info.LastWriteTime < ftpdate Then '如果ftp上的文件更新则下载
30 'Output.Show(ftpfile)
31 args(1).Download(ftpfile,locfile,True)
32 End If
33 End If
34 End If
35 'Output.Show()
36 Next