System.Drawing.Bitmap Parameter is not valid

I am having this error:

parameter is not valid.

On this line:

System.Drawing.Bitmap("~\\father\\chocolate.png");
Jon Skeet
people
quotationmark

It's very unlikely that "~\\father\\chocolate.png" is a valid filename on its own - I suspect you want to map that from an ASP.NET somewhat-relative filename to a real local filename first.

For example:

var bitmap = new Bitmap(Server.MapPath("~/father/chocolate.png"));

(I'd personally suggest using forward slashes instead of backslashes here - they work just as well under Windows; they'll still work under Linux; they don't need escaping.)

people

See more on this question at Stackoverflow