以文本方式查看主题

-  Foxtable(狐表)  (http://foxtable.com/bbs/index.asp)
--  专家坐堂  (http://foxtable.com/bbs/list.asp?boardid=2)
----  [求助]ftp重复重命名的问题  (http://foxtable.com/bbs/dispbbs.asp?boardid=2&id=137546)

--  作者:晨曦396
--  发布时间:2019/7/9 11:06:00
--  [求助]ftp重复重命名的问题
假如在上传时发现ftp上有重复名称的,需要自动重命名再上传,比如加入当前的日期或其他字符进行区分,保留之前重复的,代码怎么写
--  作者:有点蓝
--  发布时间:2019/7/9 11:34:00
--  
比如:

Dim ftp1 As New FtpClient
ftp1.Host="196.128.143.28"
ftp1.Account = "foxuser"
ftp1.Password = "138238110"
Dim file As String = "jz.png"
If ftp1.FileExists("\\photo\\" & file) Then
    file = file.Split(".")(0) & Format(Date.Now,"yyyyMMddHHmmssfffff") & ".png"
End If
If ftp1.Upload("c:\\data\\Desert.jpg","\\photo\\" & file ) = True Then
    Messagebox.show("上传完成!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
Else
    Messagebox.show("上传失败!","提示",MessageBoxButtons.OK,MessageBoxIcon.Information)
End If