GDI +中发生System.Drawing.Image.Save一般性错误错误、发生、System、GDI

2023-09-03 01:25:32 作者:一隅长安

例外:的

Exception:

GDI +中发生一般性错误。    在System.Drawing.Image.Save(字符串文件名,图片codecInfo EN codeR,恩coderParameters EN coderParams)    在System.Drawing.Image.Save(字符串文件名,格式的imageformat)    在System.Drawing.Image.Save(字符串文件名)

A generic error occurred in GDI+. at System.Drawing.Image.Save(String filename, ImageCodecInfo encoder, EncoderParameters encoderParams) at System.Drawing.Image.Save(String filename, ImageFormat format) at System.Drawing.Image.Save(String filename)

code:的

Code:

byte[] bitmapData = new byte[imageText.Length];
MemoryStream streamBitmap;
bitmapData = Convert.FromBase64String(imageText);
streamBitmap = new MemoryStream(bitmapData);
System.Drawing.Image img = Image.FromStream(streamBitmap);
img.Save(path);

我们转换一个base64字符串到MemoryStream,然后创建一个System.Drawing.Image对象(Image.FromStream(streamBitmap))。 在结束的图像保存在一个临时文件。

We convert a base64 string into a MemoryStream and then create a System.Drawing.Image (Image.FromStream(streamBitmap)). At the end the image is saved in a temp file.

但奇怪的是,这个问题似乎发生时的活动(并发用户数)为高电平时,Web服务器上的问题是一个IISRESET或应用程序池回收后,暂时解决了......

The strange thing is that the problem seems to occur when the activity (number of concurrent users) is high on the web server and the problem is solved temporarily after an IISRESET or an application pool recycle...

==>垃圾收集器的问题?

==> Garbage collector issue ?

我已经检查TEMP文件夹的权限...

I already checked the permission of the TEMP folder...

推荐答案

在你加载imagefrom甲流,你必须保持流打开图像的一生中,看到的