Dim 当前目录 As String = e.Form.Controls("当前目录").text
Dim 刷新 As WinForm.Button = e.Form.Controls("刷新")
Dim curtable As Table = vars("tabc")
Dim curColName As String = curtable.Cols(curtable.ColSel).Name
Dim curCol As DataCol = curtable.DataTable.datacols(curColName)
Dim dr As DataRow = curtable.Current.DataRow
Dim openFilter As String = ""
Dim tpBl As Boolean = False
' 判断是否是图片列
If curCol.ExtendType = ExtendTypeEnum.Images Then
openFilter = "文件|*.jpeg;*.bmp;*.jpg;*.png;*.gif"
tpBl = True
Else
openFilter = "所有文件|*.*"
End If
Dim dlg As New OpenFileDialog ' 定义一个新的OpenFileDialog
dlg.Filter = openFilter ' 设置筛选器
dlg.MultiSelect = True
If dlg.ShowDialog = DialogResult.OK Then ' 如果用户单击了确定按钮
Dim upOk As New List(Of String)
Dim upNok As New List(Of String)
Dim result As New List(Of String)
For Each fl As String In dlg.FileNames
Dim fl2 As String = fl
If tpBl Then
' 压缩图片
fl2 = Functions.Execute("压缩图片", fl, 350)
If fl2 Is Nothing Then Continue For
End If
Dim flname As String = FileSys.GetName(fl2)
Dim 目标路径 As String = 当前目录 & "\" & flname
' 将文件复制到本地目录
Try
FileSys.CopyFile(fl2, 目标路径, True)
upOk.Add("上传成功: " & flname)
result.Add(目标路径)
Catch ex As Exception
upNok.Add("上传失败: " & flname)
Dim tishi As String = String.Join(vbCrLf, upNok.ToArray)
MessageBox.Show(tishi) ' 新增的,上传失败必须提示
End Try
' 删除压缩后的临时文件
If tpBl Then
FileSys.DeleteFile(fl2)
End If
Next
' 把成功的添加到记录里面
For Each s As String In dr.Lines(curColName)
If result.Contains(s) Then Continue For
result.Add(s)
Next
dr.Lines(curColName) = result
刷新.PerformClick()
End If
文件管理器窗口如图:
此主题相关图片如下:微信截图_20250315191944.png

双击打开文件时报错:
此主题相关图片如下:微信截图_20250315191957.png
