以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  FTP管理器的自动更新文件功能如何实现?  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=162370)

--  作者:wh420
--  发布时间:2021/4/12 21:22:00
--  FTP管理器的自动更新文件功能如何实现?
现在用LISTVIEW来实现文件管理:

如果本地存在此文件,会将此文件和FTP上的文件进行比较,如果FTP上的文件比较新,将重新从FTP下载并打开此文件,否则直接打开本地文件。
本地是否存在此文件我会,但如何实现此文件与FTP上的文件比较?麻烦老师帮忙代码指导一下。




--  作者:有点蓝
--  发布时间:2021/4/12 21:25:00
--  
参考:http://www.foxtable.com/webhelp/topics/1410.htm

GetFileTime

返回ftp上指定文件最后一次修改的日期时间。

Dim ftp1 As New FtpClient
ftp1
.Host="196.128.143.28"
ftp1
.Account = "foxuser"
ftp1
.Password = "138238110"
Dim 
sz As Date
sz = ftp1.GetFileTime(
"\\photo\\jz.png")
Output.Show(
"修改时间:" & sz)


--  作者:wh420
--  发布时间:2021/4/12 21:53:00
--  
每次打开本地文件,什么都不操作(如:JPG)最后一次的修改时间都会变,这样与FTP的文件修改时间总是不相等,怎么办?

LastWriteTime 
GetFileTime

--  作者:wh420
--  发布时间:2021/4/12 22:02:00
--  
老师帮忙看看我写的代码,每次执行都是重新下载,而不是直接打开本地文件。

Dim ftpsz As Date
Dim sz As Date

Dim ftp1 As New FTPClient
ftp1.Host=FtpIp
ftp1.Account = FtpUser
ftp1.Password = FtpPass

Dim bh As String = "\\" & Tables("表A").current("xmid") & "\\"
Dim localpath As String = projectpath & "RemoteFiles" &  bh & FileSys.GetName(e.sender.Current("FileName"))
Dim ifo As new FileInfo(localpath)

ftpsz = ftp1.GetFileTime(e.sender.Current("FileName"))
sz=ifo.LastWriteTime

If FileSys.FileExists(localpath) AndAlso ftpsz=sz Then
    \'文件存在直接打开!","提示")
    Dim Proc As New Process \'定义一个新的Process
    Proc.File = localpath 
    Proc.Start()
Else
    ftp1.Download(e.sender.Current("FileName"), localpath , True)
    Dim Proc As New Process \'定义一个新的Process
    Proc.File = localpath
    Proc.Start()

End If
ftp1.Close()

--  作者:有点蓝
--  发布时间:2021/4/12 22:31:00
--  
If FileSys.FileExists(localpath) AndAlso ftpsz <= sz Then