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