空路径名不合法(vb.net 2005,access 2000,)
[错误]空路径名不合法 问题是我无法插入图像以访问数据库。哪一行是错误的。提前感谢帮助我的人 问候,, 菲祖尔空路径名不合法(vb.net 2005,access 2000,),vb.net,ms-access,Vb.net,Ms Access,[错误]空路径名不合法 问题是我无法插入图像以访问数据库。哪一行是错误的。提前感谢帮助我的人 问候,, 菲祖尔 问题在于前两行: Dim OpenFileDialog1 As New OpenFileDialog Dim fsreader As New IO.FileStream(OpenFileDialog1.FileName,IO.FileMode.Open, IO.FileAccess.Read) 您创建了OpenFileDialog的实例,但从未调用它的ShowDialog方法,因此F
问题在于前两行:
Dim OpenFileDialog1 As New OpenFileDialog
Dim fsreader As New IO.FileStream(OpenFileDialog1.FileName,IO.FileMode.Open, IO.FileAccess.Read)
您创建了OpenFileDialog的实例,但从未调用它的ShowDialog方法,因此FileName属性为Nothing。你需要这样的东西:
Using OpenFileDialog1 As New OpenFileDialog
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
Dim fsreader As New IO.FileStream(OpenFileDialog1.FileName,IO.FileMode.Open, IO.FileAccess.Read)
'remaining of code here
End If
End Using
Using
语句确保对话框被正确处理
Using OpenFileDialog1 As New OpenFileDialog
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
Dim fsreader As New IO.FileStream(OpenFileDialog1.FileName,IO.FileMode.Open, IO.FileAccess.Read)
'remaining of code here
End If
End Using