为什么MemoryStream写不进字节数组
FileStream fs = new FileStream( "1.data ",FileMode.OpenOrCreate,FileAccess .ReadWrite );
BinaryWriter bWriter = new BinaryWriter(fs);
Image image1 = Image.FromFile(@ "F:\中软培训\c#.net培训\课堂举例\5_7\TelBook3\TelBook\bin\Debug\Sunset.jpg ");
MemoryStream ms = new MemoryStream();
image1.Save(ms, ImageFormat.Jpeg);
byte[] buffer = new byte[ms.Length];
ms.Read(buffer, 0, (int)ms.Length );
ms.Flush ();
bWriter.Flush();
fs.Flush();
ms.Close();
bWriter.Close();
fs.Close();
我调试的时候发现,buffer是空的,为什么写不进去啊
------解决方案--------------------确定ms里面确实有值吗?
byte[] buffer = new byte[ms.Length];
ms.Position = 0;
ms.Read(buffer, 0, (int)ms.Length );
ms.Flush ();
这样写还不行?不可能的事。