-1

每当我试图将图像保存在指定的字符串路径中时,我都会不断收到 GDI+ 错误。这是代码:你能告诉我吗?

        System.Drawing.Image newImage;
        byte[] b= (byte[])Session["Image"];
        using (MemoryStream stream = new MemoryStream(b))
        {
            newImage = System.Drawing.Image.FromStream(stream); 
            newImage.Save("C:\\test.png"); //this is where the GDI+ error is thrown
            Image1.Attributes.Add("src", "C:\\test");

        }
4

1 回答 1

1

是否需要将字节转换为图像,然后再将图像转换为字节?

否则,您可以直接保存字节:

File.WriteAllBytes("C:\\test.png", (byte[])Session["Image"]);
于 2013-05-03T10:28:46.623 回答