Get File Path From Dialog Box

Lanc1988

Contributor
Joined
Nov 27, 2003
Messages
508
I have a program where the user can change the background image of the form. Right now I just have about 5 images they can choose and when they choose a new image it saves to a file so that when they open the program again it will load the right image for the background. I want to add a custom option so they can choose a image file but I can't figure out how to get the file path and file name from the dialog box.
 
What dialog box? The FileOpenDialog? Your own?

If you are using the FileOpenDialog then you just read the FileName property.
 
marble_eater said:
What dialog box? The FileOpenDialog? Your own?

If you are using the FileOpenDialog then you just read the FileName property.

I'm using the FileOpenDialog. So the FileName property will get the the name of the file but what will get me the path for it?
 
ok, i got it all to work the way I wanted. now im trying to get the dialog box to filter but its now working, so far I have and it works fine:

dialogCustomTheme.Filter = "Image Files (*.jpg)|*.jpg"

But I want to have more than just jpg so I tried things like but it doesnt work:

dialogCustomTheme.Filter = "Image Files (*.jpg)|*.jpg, *.bmp, *.png"
 
This example is straight from the MSDN documentation. All you have to do is in your second part of the filter separate them using the semicolon instead of a comma.
Visual Basic:
Image Files(*.BMP;*.JPG;*.GIF)|*.BMP;*.JPG;*.GIF|All files (*.*)|*.*
 
Back
Top