how to convert image from file path to bitmap in c#

c#

Solution

That usually just works, are you using an escape character to escape the escape character? Example:

Bitmap bm = new Bitmap("D:\\newfolder\\1.jpg");
//Notice the \\ the second \ escapes the first

Or escape it like this:

Bitmap bm = new Bitmap(@"D:\newfolder\1.jpg");
//Notice the @ in front of the string, that means ignore the escape characters

Your original string doesn't escape this and thus inserts a newline (`\n`).

Problem

``` Bitmap bmp = new Bitmap("D:\1.jpg"); ``` The exception I get is: parameter is not valid. How can I solve this?

Original source