存储imagestring image = txtImage.Text.Trim();
FileInfo MyPicture = new FileInfo(image);
byte[] content = new byte[MyPicture.Length];
FileStream ImageFileStream = MyPicture.OpenRead();
ImageFileStream.Read(content, 0, content.Length);
ImageFileStream.Close();读取imagebyte[] imageData = (byte[])dr["IMAGE"];
this._myMemoryStreamIn = new MemoryStream(imageData, 0, imageData.Length);
img = Image.FromStream(this._myMemoryStreamIn);
this._myMemoryStreamIn.Close();
this.pic.Image = img;可是我在数据库里 copy一条数据加进去 读取的时候就要报错 img = Image.FromStream(this._myMemoryStreamIn); //Parameter is not valid.

解决方案 »

  1.   

    this._myMemoryStreamIn = new MemoryStream(imageData, 0, imageData.Length);
    在这句设置断点,看看值是多少。
      

  2.   

    this._myMemoryStreamIn = new MemoryStream(imageData, 0, imageData.Length); 
      

  3.   

    直接用你存储image时候的content数组作为源数据运行读取image,代码是OK的
    数据库取出来的dr["IMAGE"]应该是binary类型的吧?你可以试下检查content和imageData两个byte数组在处理同一image时,长度是否一致,内容是否一样