用:按钮上传,比如这样
Dim dlg As New openFileDialog '定义一个新的SaveFileDialog
dlg.MultiSelect = True
If dlg.showDialog = DialogResult.Ok Then '如果用户单击了确定按钮
Dim ftp1 As new ftpclient
ftp1.host="127.****.0"
ftp1.Account = "ft***"
ftp1.password = "1****"
Dim r As Row = Tables("计量产值统计表").Current
Dim ls = r.DataRow.Lines("附件")
For Each f As String In dlg.FileNames
Dim d As String = Format(Date.Today ,"yyyyMM") '格式化日期为202103
Dim file = "/计量产值管理/" & r("项目名称") & "/" & d & "/" & filesys.GetName(f)
If ftp1.DirExists("/计量产值管理/" & r("项目名称")) = False Then
ftp1.MakeDir("/计量产值管理/" & r("项目名称"))
End If
If ftp1.DirExists("/计量产值管理/" & r("项目名称") & "/" & d) = False Then
ftp1.MakeDir("/计量产值管理/" & r("项目名称") & "/" & d)
End If
Dim Result As DialogResult
If ftp1.FileExists(file) Then
Result = MessageBox.Show("文件已经存在,是否覆盖?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
End If
If result = Nothing OrElse result = DialogResult.Yes Then
If ftp1.Upload(f,file,True) = True Then
If ls.contains(file) = False Then
ls.add(file)
End If
Else
MessageBox.Show( f & "上传失败" ,"提示" ,MessageBoxButtons.OK,MessageBoxIcon.Question)
End If
End If
Next
r.DataRow.lines("附件") = ls
ftp1.Close
End If
[此贴子已经被作者于2022/5/24 9:54:39编辑过]