Click here to Skip to main content
15,913,282 members
Home / Discussions / Visual Basic
   

Visual Basic

 
GeneralRe: Changing Image From File Pin
EvanSaunders6-Sep-07 2:22
EvanSaunders6-Sep-07 2:22 
GeneralRe: Changing Image From File Pin
Dave Kreskowiak6-Sep-07 3:16
mveDave Kreskowiak6-Sep-07 3:16 
GeneralRe: Changing Image From File Pin
EvanSaunders6-Sep-07 21:58
EvanSaunders6-Sep-07 21:58 
AnswerRe: Changing Image From File Pin
Luc Pattyn6-Sep-07 3:51
sitebuilderLuc Pattyn6-Sep-07 3:51 
GeneralRe: Changing Image From File Pin
EvanSaunders6-Sep-07 22:08
EvanSaunders6-Sep-07 22:08 
GeneralRe: Changing Image From File Pin
Luc Pattyn7-Sep-07 1:32
sitebuilderLuc Pattyn7-Sep-07 1:32 
GeneralRe: Changing Image From File Pin
EvanSaunders9-Sep-07 22:31
EvanSaunders9-Sep-07 22:31 
GeneralRe: Changing Image From File Pin
Dave Kreskowiak7-Sep-07 2:05
mveDave Kreskowiak7-Sep-07 2:05 
EvanSaunders wrote:
I loaded the images into the resources folder, and then when I change the image of a button when hovered over by the mouse, I can just call it from the resources directly.


I had no idea you were changing the images on the buttons using Image.FromFile().

This is definitely the proper way to go when dealing with the images on controls like you are. Loading from resources is quicker than loading from files as the mouse passes over them.


EvanSaunders wrote:
Apperantly, when loading the project/system, the default directory is set to the ../bin/debug/ folder.


The CurrentDirectory is set to whatever folder the .EXE was launched from. The problem you, apparently, ran into is that you used relative paths (actually, NO path) in your code to load the image files. When the CurrentDirectory changed, so did the path that your code assumed was the correct path to find those image files.

It's good practice to always build and use fully qualified paths to any files that your app uses. An example of such:
Dim imageFilepath As String = Path.Combine(Application.StartupPath, "image.bmp")

This code doesn't rely on the current directory at all. It relys on a known path that cannot change during the lifetime of the applications session and just appends the filename to this known path. The CurrentDirectory can change all it wants and it won't affect this code.


A guide to posting questions on CodeProject[^]

Dave Kreskowiak
Microsoft MVP
Visual Developer - Visual Basic
     2006, 2007


GeneralRe: Changing Image From File Pin
EvanSaunders9-Sep-07 22:32
EvanSaunders9-Sep-07 22:32 
Questionhelp for the code Pin
MidoYC5-Sep-07 19:42
MidoYC5-Sep-07 19:42 
AnswerRe: help for the code Pin
Guffa5-Sep-07 20:39
Guffa5-Sep-07 20:39 
AnswerRe: help for the code Pin
Luc Pattyn6-Sep-07 3:56
sitebuilderLuc Pattyn6-Sep-07 3:56 
QuestionCrystal Report Pin
aqui_i5-Sep-07 15:59
aqui_i5-Sep-07 15:59 
AnswerRe: Crystal Report Pin
Lucky Sheikh6-Sep-07 20:25
Lucky Sheikh6-Sep-07 20:25 
QuestionRun program in back ground Pin
Cory Kimble5-Sep-07 10:59
Cory Kimble5-Sep-07 10:59 
AnswerRe: Run program in back ground Pin
Colin Angus Mackay5-Sep-07 14:15
Colin Angus Mackay5-Sep-07 14:15 
AnswerRe: Run program in back ground Pin
astanton19786-Sep-07 2:25
astanton19786-Sep-07 2:25 
QuestionTranslating C structure into VB.NET Pin
Ravi Mahavrathayajula5-Sep-07 7:59
Ravi Mahavrathayajula5-Sep-07 7:59 
AnswerRe: Translating C structure into VB.NET Pin
Christian Graus5-Sep-07 8:30
protectorChristian Graus5-Sep-07 8:30 
GeneralRe: Translating C structure into VB.NET Pin
Ravi Mahavrathayajula5-Sep-07 8:48
Ravi Mahavrathayajula5-Sep-07 8:48 
GeneralRe: Translating C structure into VB.NET Pin
Dave Kreskowiak5-Sep-07 9:05
mveDave Kreskowiak5-Sep-07 9:05 
GeneralRe: Translating C structure into VB.NET Pin
Ravi Mahavrathayajula5-Sep-07 9:30
Ravi Mahavrathayajula5-Sep-07 9:30 
GeneralRe: Translating C structure into VB.NET Pin
Ravi Mahavrathayajula5-Sep-07 9:47
Ravi Mahavrathayajula5-Sep-07 9:47 
GeneralRe: Translating C structure into VB.NET Pin
Dave Kreskowiak5-Sep-07 10:07
mveDave Kreskowiak5-Sep-07 10:07 
QuestionAddressOf with arguments Pin
Amer Rehman5-Sep-07 7:58
Amer Rehman5-Sep-07 7:58 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.