Parameter is not valid - Bitmap bmp = New Bitmap()


  • I have a grass image located here in my directory. I want to just create a Bitmap, but I am getting an error. (Parameter is not valid.)
    Immediate Window:

    A first chance exception of type 'System.ArgumentException' occurred in System.Drawing.dll

    Why is this?

            private void Form1_Load(object sender, EventArgs e)
                Bitmap bmp = new Bitmap("grass.jpg");

    Wednesday, February 10, 2010 3:25 PM


  • You have 2 possibilities

    1. provide the complete filename
    2. copy the image to your \bin\debug folder ( for running in the ide )


    If you have got questions about this, just ask.
    Mark the thread as answered if the answer helps you. This helps others who have the same problem !
    C# to VB.NET:
    • Proposed as answer by bpell Wednesday, February 10, 2010 3:47 PM
    • Marked as answer by bertino Wednesday, February 10, 2010 3:51 PM
    Wednesday, February 10, 2010 3:42 PM

All replies