Dim dlg As New OpenFileDialog
Dim flm As WinForm.FileManager = Tables("患者诊疗记录").Cols("B超图片").FileManager
dlg.Filter= "JPG图片|*.jpg|png图片|*.png|Excel文件|*.xls|Word文件|*.doc|Access文件|*.mdb"
If dlg.ShowDialog = DialogResult.OK Then
Dim pth As String = ProjectPath & "Attachments\"
If dlg.FileName.ToLower.StartsWith(pth.ToLower) Then '如果文件来自Attachments目录
flm.AddFile(dlg.FileName.SubString(pth.Length))
Else '如果不是
Dim ext As String
ext = dlg.FileName.SubString(dlg.FileName.LastIndexof(".") + 1)
Dim name As String=Format(Date.now, "D") & "_" & Date.now.hour & "时" & Date.now.Minute & "分" & Date.now.Second & "秒" & e.Sender.name & "." & ext
FileSys.CopyFile(dlg.FileName, pth & FileSys.GetName(Name))
flm.AddFile(FileSys.GetName(Name))
End If
End If