Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / Windows Forms / WinForm General / March 2006

Tip: Looking for answers? Try searching our database.

FileNotFound Exception for OnHover after FileOpen.ShowDialog

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Stork - 28 Feb 2006 22:44 GMT
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?
Stoitcho Goutsev (100) - 01 Mar 2006 14:28 GMT
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.

Signature

HTH
Stoitcho Goutsev (100)

> Hi,
>
[quoted text clipped - 36 lines]
>
> Any idea on how I can get around this problem?
Stork - 01 Mar 2006 17:51 GMT
Works great, thanx!

>Stork,
>
[quoted text clipped - 10 lines]
>>
>> Any idea on how I can get around this problem?

Rate this thread:







Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.