Omu
Omu

Reputation: 71208

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

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, jpegCodec, 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 ?

Upvotes: 1

Views: 1279

Answers (1)

Mikael Östberg
Mikael Östberg

Reputation: 17156

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.

Upvotes: 4

Related Questions