代码改变世界

C#asp.net与Wnfrom常见问题实例

2010-04-04 19:51  苏飞  阅读(177)  评论(0)    收藏  举报

1.怎么样把图片保存成字节?                                                                                                                                                                        

第一种方式

代码
    //Save image from PictureBox into MemoryStream object.
    MemoryStream ms  = new MemoryStream();
    pictureBox1.Image.Save(ms, ImageFormat.Jpeg);

    
//Read from MemoryStream into Byte array.
    Byte[] bytBLOBData = new Byte[ms.Length];
    ms.Position 
= 0;
    ms.Read(bytBLOBData, 
0, Convert.ToInt32(ms.Length));

 

bytBLOBData就是你要的字节数组了

 

第二种方式

代码
            codeMemoryStream ms = new MemoryStream();
            pictureBox1.Image.Save(ms, System.Drawing.Imaging.ImageFormat.Bmp);
            
byte[] bytes = ms.GetBuffer();
            ms.Close();
            ms.Dispose();

 

bytes就是你想要的字节数组了

 2.C#是怎么们存取图片的?

 

     小谈c#数据库存取图片的方式

3.怎么样强制清理界面缓存

 

    <meta http-equiv="pragma " content="no-cache ">
    
<meta http-equiv="Cache-Control " content="no-cache,   must-revalidate ">
    
<meta http-equiv="expires " content="Wed,   26   Feb   1978   08:21:57   GMT ">