各位大神,帮我看看这到底是怎么错的。
Dim picture_Bytes() As Byte = DataSet14.Tables(0).Rows(i).Item(0)
Dim S As New System.IO.MemoryStream(picture_Bytes)
Dim myfilestream As New System.IO.FileStream("f:\vb\test.bmp", IO.FileMode.Create)
myfilestream.Write(picture_Bytes, 0, picture_Bytes.Length)
PictureBox1.Image = Image.FromStream(S, True) '窗体中显示图片
最后一句提示参数无效,当我用myfilestream方法把DataSet14.Tables(0).Rows(i).Item(0)中内容存成bmp格式的图片是里面没有预览,看不到任何东西,但picture_Bytes有length值。
------解决思路----------------------
下面两种试试
Dim picture_Bytes() As Byte = DataSet14.Tables(0).Rows(i).Item(0)
Dim S As New System.IO.MemoryStream(picture_Bytes)
'Dim myfilestream As New System.IO.FileStream("f:\vb\test.bmp", IO.FileMode.Create)
'myfilestream.Write(picture_Bytes, 0, picture_Bytes.Length)
PictureBox1.Image = Bitmap.FromStream(S) '窗体中显示图片
或
Try
Dim data As Byte() = DataSet14.Tables(0).Rows(i).Item(0)
Dim myfilestream As New System.IO.FileStream(Application.StartupPath & "\monkey.bmp", IO.FileMode.Create)
myfilestream.Write(data, 0, data.Length)
myfilestream.Close()
PictureBox1.Image = New Bitmap(Application.StartupPath & "\monkey.bmp")
Catch
End Try