System.IO.MemoryStream ms = new System.IO.MemoryStream();
            Bitmap bm = new Bitmap("c:\\5.jpg ");
            bm.Save(ms, System.Drawing.Imaging.ImageFormat.Jpeg);
            byte[] byt = new byte[ms.Length];
            ms.Seek(0, System.IO.SeekOrigin.Begin);//here
            ms.Read(byt, 0, (int)ms.Length);
            //我把一副图片保存到内存流ms里,在读到byt数组里。 
            //然后在将byt数组写入另一个内存流ma,我的Bitmap对象就无法创建了。这是为什么,请各位高手帮忙,非常感谢。 
            System.IO.MemoryStream ma = new System.IO.MemoryStream();
            ma.Write(byt, 0, byt.Length);
            ma.Seek(0, System.IO.SeekOrigin.Begin);//here
            

解决方案 »

  1.   

                System.IO.MemoryStream ms = new System.IO.MemoryStream();
                Bitmap bm = new Bitmap( @"C:\Documents and Settings\All Users\Documents\My Pictures\Sample Pictures\Water lilies.jpg" );
                bm.Save( ms, System.Drawing.Imaging.ImageFormat.Jpeg );
                //byte[] byt = new byte[ ms.Length ];
                //ms.Read( byt, 0, ( int )ms.Length );
                //我把一副图片保存到内存流ms里,在读到byt数组里。
                //然后在将byt数组写入另一个内存流ma,我的Bitmap对象就无法创建了。这是为什么,请各位高手帮忙,非常感谢。
                //System.IO.MemoryStream ma = new System.IO.MemoryStream();
                //ma.Write( byt, 0, byt.Length );
                Bitmap bt = new Bitmap( ms );//这里报错参数无效,我晕了
                //Bitmap   bt=new   Bitmap(ms);//这样就不会报错,真的很怪。
                pictureBox1.Image = bt;
    这样不就可以了?为什么要再读一遍?
      

  2.   

    同意楼上,你先要把流的当前位置设置到0偏移量位置,因为Write后当前位置在流的最末位了。