Hi,

I have a program that has a row of buttons that use MouseEnter/MouseLeave to
change between two different colored images. I also have other images that I
pull from the filing system. Since I have several thousands pictures of
product, putting the images in an ImageList is out of the question as that
would make the EXE file insanely huge and eat up tons of resources.

My problem is I am trying to avoid having to type the full path of the images
(C:\Program Files\etc) so that no matter where a user installs the program,
and no matter the drive letter/name, it will work correctly. Everything works
fine until I open the Save or Open Dialog box, and then when an image is
pulled from the file system it throws up a 'File Not Found Exception'.


Code:
private void btnSave_Click(object sender, EventArgs e)
{
fileSave.ShowDialog();
}

private void btnSave_MouseEnter(object sender, EventArgs e)
{
btnSave.Image = System.Drawing.Image.FromFile(@"Images\Main\save-
oj.jpg");
}

private void btnSave_MouseLeave(object sender, EventArgs e)
{
btnSave.Image = System.Drawing.Image.FromFile(@"Images\Main\save-
blu.jpg");
}

Any idea on how I can get around this problem?

--
Message posted via http://www.dotnetmonster.com

Re: FileNotFound Exception for OnHover after FileOpen.ShowDialog by Stoitcho

Stoitcho
Wed Mar 01 08:28:36 CST 2006

Stork,

You assume that the current working folder is the parent folder of Images.
It looks like this is not the case. Normally when the application starts the
working folder is the folder of the exe, but can be changed.

I suggest to use Application.StartupPath to get the folder of the executable
and then construct your path from there.


--
HTH
Stoitcho Goutsev (100)

"Stork via DotNetMonster.com" <u16488@uwe> wrote in message
news:5c932c1aa8e22@uwe...
> Hi,
>
> I have a program that has a row of buttons that use MouseEnter/MouseLeave
> to
> change between two different colored images. I also have other images that
> I
> pull from the filing system. Since I have several thousands pictures of
> product, putting the images in an ImageList is out of the question as that
> would make the EXE file insanely huge and eat up tons of resources.
>
> My problem is I am trying to avoid having to type the full path of the
> images
> (C:\Program Files\etc) so that no matter where a user installs the
> program,
> and no matter the drive letter/name, it will work correctly. Everything
> works
> fine until I open the Save or Open Dialog box, and then when an image is
> pulled from the file system it throws up a 'File Not Found Exception'.
>
>
> Code:
> private void btnSave_Click(object sender, EventArgs e)
> {
> fileSave.ShowDialog();
> }
>
> private void btnSave_MouseEnter(object sender, EventArgs e)
> {
> btnSave.Image =
> System.Drawing.Image.FromFile(@"Images\Main\save-
> oj.jpg");
> }
>
> private void btnSave_MouseLeave(object sender, EventArgs e)
> {
> btnSave.Image =
> System.Drawing.Image.FromFile(@"Images\Main\save-
> blu.jpg");
> }
>
> Any idea on how I can get around this problem?
>
> --
> Message posted via http://www.dotnetmonster.com



Re: FileNotFound Exception for OnHover after FileOpen.ShowDialog by Stork

Stork
Wed Mar 01 11:51:44 CST 2006

Works great, thanx!

Stoitcho Goutsev (100) wrote:
>Stork,
>
>You assume that the current working folder is the parent folder of Images.
>It looks like this is not the case. Normally when the application starts the
>working folder is the folder of the exe, but can be changed.
>
>I suggest to use Application.StartupPath to get the folder of the executable
>and then construct your path from there.
>
>> Hi,
>>
>[quoted text clipped - 36 lines]
>>
>> Any idea on how I can get around this problem?

--
Message posted via http://www.dotnetmonster.com