Foxtable(狐表)用户栏目专家坐堂 → 图片文件判断是否重复


  共有2148人关注过本帖树形打印复制链接

主题:图片文件判断是否重复

美女呀,离线,留言给我吧!
nuonuo384
  1楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:幼狐 帖子:63 积分:866 威望:0 精华:0 注册:2020/2/4 9:55:00
图片文件判断是否重复  发帖心情 Post By:2020/3/11 15:43:00 [只看该作者]

老师:

     我在窗口中添加按钮,点击后在指定列表框添加附件,代码如下。  因为如果子目录中同名会覆盖,怎样判断该名称是否存在?

Dim ftp1 As New FtpClient
Dim sourceFileName, destinationFileName As String
ftp1.Host = "47.102.150.86"
ftp1.Account = "test"
ftp1.Password = "67963270"
ftp1.UTF8 = True
If ftp1.DirExists("\" & user.name & "\" &  Date.Today ) = False Then
    ftp1.MakeDir("\" & user.name & "\" &  Date.Today )
End If
If dlg.showdialog = dialogresult.ok Then
    For Each fl As String In dlg.FileNames
        flname = fl.Substring(fl.LastIndexOf("\")+1)
        flname = "\" & user.name & "\" &  Date.Today & "\"  & flname 
        ls = ls & "|" & flname & "|"
        lst1.ComboList = ls
        If ftp1.Upload(fl, flname) = True Then
            Messagebox.show("上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        Else
            Messagebox.show("上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
        End If
    Next
End If



 回到顶部
帅哥,在线噢!
有点蓝
  2楼 | 信息 | 搜索 | 邮箱 | 主页 | UC


加好友 发短信
等级:超级版主 帖子:107135 积分:544918 威望:0 精华:9 注册:2015/6/24 9:21:00
  发帖心情 Post By:2020/3/11 15:45:00 [只看该作者]

FileExists

判断指定的文件是否存在,语法:

FileExists(FileName)

FileName:要判断的文件名,含路径。

示例

Dim ftp1 As New FtpClient
ftp1.Host=
"196.128.143.28"
ftp1.Account = 
"foxuser"
ftp1.Password = 
"138238110"
If 
ftp1.FileExists("\photo\jz.png") Then '如果存在则下载
    
If ftp1.Download("\photo\jz.png","c:\data\jz.png"Then
        messagebox.Show(
"下载完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    
Else
        messagebox.Show(
"下载失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
    
End If
Else

    messagebox.Show(
"此文件不存在!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End
 If


 回到顶部