C# image changer help

ok i am trying to click a button and when i click it , it will change the BackGroundImage. here the code for it .
[code]
private void button1_Click_1(object sender, System.EventArgs e)
{
Image image = Image.FromFile("C:\j.jpeg");
Image picture = Image.FromFile("C:\h.jpeg");
int i;
i = 2;
if( i > 3)
{
BackgroundImage = picture;
}
else
BackgroundImage = image;
}
[/code]
and then i get this message after it excutes with no errors
An unhandled exception of type 'System.IO.FileNotFoundException' occurred in system.drawing.dll
additional information: C:j.jpeg

Comments

  • : ok i am trying to click a button and when i click it , it will change the BackGroundImage. here the code for it .
    : [code]
    : private void button1_Click_1(object sender, System.EventArgs e)
    : {

    if (!System.IO.File.Exists("C:\j.jpeg"))
    {
    MessageBox.Show("There is no such file as C:\j.jpeg");
    return;
    }

    : Image image = Image.FromFile("C:\j.jpeg");

    if (!System.IO.File.Exists("C:\h.jpeg"))
    {
    MessageBox.Show("There is no such file as C:\h.jpeg");
    return;
    }

    : Image picture = Image.FromFile("C:\h.jpeg");
    : int i;
    : i = 2;
    : if( i > 3)
    : {
    : BackgroundImage = picture;
    : }
    : else
    : BackgroundImage = image;
    : }
    : [/code]
    : and then i get this message after it excutes with no errors
    : An unhandled exception of type 'System.IO.FileNotFoundException' occurred in system.drawing.dll
    : additional information: C:j.jpeg
    :

  • try use a bmp or PNG file format. If you convert the c.jpeg file to either c.bmp or c.PNG, it will work
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories