Dim dlg As new OpenFileDialog
If dlg.ShowDialog = DialogResult.OK Then
Dim xg As Integer = dlg.FileName.LastIndexOf("\")
Dim fname As String = dlg.FileName.SubString(xg + 1) '获取所选文件名称 ABC.jpg
Dim ftp As new FTPClient
ftp.Host = "222.216.28.13"
ftp.Account = "gongling"
ftp.Password = "1CCCEC22128b97"
Dim fp As String = "\gongling\web\FTP测试\" & Tables("表A").Current("自制")
Dim sts As List(of String) = ftp.GetFileList(fp) '获取当前目录的文件列表
If sts.Count > 0 Then
For Each st As String In sts
If st = fname Then
MessageBox.Show("服务器上存在同名文件!","提醒")
Return '这里是简化了操作,读者可以自己做是否覆盖的功能
End If
Next
End If
e.Form.text = "ftp管理器 文件上传中...."
If ftp.Upload(dlg.FileName,fp & "\" & fname) = True Then '若成功上传
Functions.Execute("刷新ListView")
e.Form.text = "ftp管理器"
MessageBox.Show("上传成功!","提醒")
Else
MessageBox.Show("上传失败!","提醒")
e.Form.text = "ftp管理器"
End If
End If