上面的代码,不会报你3楼的错。
Dim dlg As New OpenFileDialog
Dim piv As WinForm.PictureViewer = e.Form.Controls("PictureViewer1")
dlg.Filter= "图形文件|*.bmp;*.jpg;*.gif"
If dlg.ShowDialog = DialogResult.OK Then
Dim pth As String = ProjectPath & "Attachments\"
Dim fname As String = e.Form.Controls("学生姓名").Text
If dlg.FileName.ToLower.StartsWith(pth.ToLower) Then '如果文件来自Attachments目录
FileSys.RenameFile(dlg.FileName, pth & fname)
piv.AddFile(fname)
Else '如果不是
FileSys.CopyFile(dlg.FileName, pth & fname)
piv.AddFile(fname)
End If
End If