Dim frm As WinForm.Form = Forms("文件上传模式窗口")
If frm.Opened Then
e.Cancel = True
Dim dlg As New openFileDialog '定义一个新的SaveFileDialog
dlg.Filter= "文件|*.txt;*.bmp;*.jpg;*.png;*.pdf;*.doc;*.docx;*.xls;*.xlsx;*.rar;*.zip;*.jpeg" '设置筛选器
dlg.MultiSelect = True
If dlg.showDialog = DialogResult.Ok Then '如果用户单击了确定按钮
Dim pv As WinForm.FileManager = frm.Controls("FileManager1")
pv.FTPclient = _ftp
pv.ManagerCommand.Visible = False
pv.ConnectCommand.Visible = False
pv.FullViewCommand.Visible = False
Dim ls = e.DataRow.Lines("附件")
For Each f As String In dlg.FileNames
Dim file = "/QdgcWeb/www/upload/atta/附件/生产记录/" & e.DataRow("单据号") & "/" & filesys.GetName(f)
If _ftp.DirExists("/QdgcWeb/www/upload/atta/附件/生产记录/" & e.DataRow("单据号")) = False Then
_ftp.MakeDir("/QdgcWeb/www/upload/atta/附件/生产记录/" & e.DataRow("单据号")) '此处不可删除"/附件/",要不然会直接在 本机的RemoteFiles目录下生成编号名目录
End If
Dim Result As DialogResult
If _ftp.FileExists(file) Then
Result = MessageBox.Show("文件已经存在,是否覆盖?", "提示", MessageBoxButtons.YesNo, MessageBoxIcon.Question)
End If
If result = Nothing OrElse result = DialogResult.Yes Then
If _ftp.Upload(f,file,True) = True Then
If ls.contains(file) = False Then
ls.add(file)
pv.AddFile(file)
End If
Else
MessageBox.Show( f & "上传失败" ,"提示" ,MessageBoxButtons.OK,MessageBoxIcon.Question)
End If
End If
Next
e.DataRow.lines("附件") = ls
e.DataRow.Save
_ftp.Close
End If
End If