开发者

Generic GDI+ error when trying to save image (on 64 Windows 7)

开发者 https://www.devze.com 2023-02-16 14:09 出处:网络
I\'m trying to save an image like this (from an asp.net mvc application): public static void SaveJpeg(string path, Image img)

I'm trying to save an image like this (from an asp.net mvc application):

public static void SaveJpeg(string path, Image img)
        {
            var qualityParam = new EncoderParameter(Encoder.Quality, 100L);
            var jpegCodec = GetEncoderInfo("image/jpeg");

            var encoderParams = new EncoderParameters(1);
            encoderParams.Param[0] = qualityParam;
            img.Save(path, jpe开发者_JAVA技巧gCodec, encoderParams);
        }

I gave full control permissions for the specific folder to the IIS_IUSRS, after tried using impersonation and gave permissions to the impersonated user, but still doesn't work.

all this helps on x86 Windows

anybody knows a fix ?


Try to create a file without using GDI, like this for example:

System.IO.File.CreateText("YourPath").WriteLine("Hello");

Then you will determine if you have write issues or not.

Note that in IIS, you have to enable write permissions on that folder not only in the file system, but also in the IIS manager.

If you in fact can write a file using System.IO, try to attach WinDbg to the process which will tell you more about the COM Error GDI+ is giving you.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号