注册 登录
编程论坛 VB.NET论坛

MemoryStream保存到字节数组的问题

guchew 发布于 2017-04-09 11:24, 1837 次点击
        Dim mStream As New MemoryStream
        PictureBox1.Image.Save(mStream, System.Drawing.Imaging.ImageFormat.Jpeg) '此处成功
        Dim MyBytes(mStream.Length) As Byte
        mStream.Write(MyBytes, 0, mStream.Length)
        mStream.Close()  
         
        Dim strText As String = BitConverter.ToString(MyBytes)
        Textbox1.Text = strText
        为什么上述代码不能正确执行? Textbox1中显示的是一串0
1 回复
#2
guchew2017-04-09 20:06
找到原因了,是自己没有弄清MemoryStream.Write和MemoryStream.read的功能。代码中应该用read方法。
1