Question How to run a file from a CD if you don't know what the CD drive letter is?

Ameer27

New member
Joined
Sep 13, 2010
Messages
2
Programming Experience
Beginner
I'm creating a small program using Visual Basic 2010 Express. I'm planning to place the program on a CD, along with the files I want to run. The program will have command buttons, and each button will open a different file.

For example, if there is a file on the CD named ReadMe.txt, the user will be able to open it using the program, which is on the same disc as "ReadMe", by clicking the corresponding button (or link) ("ReadMe".)

The problem is, that I don't know what the CD drive letter will be. Is there a code to make the program run a file which is in the same location as the program? Or is there a workaround for this situation?

Thanks in advance.
 
Build the program using relative paths, meaning if your program is going to be on the root of the cd and everything else is is in a subfolder (or a few) or is on the root as well then all you need is the location of your exe file itself (you can use Application.StartupPath) and append whatever the rest of the path is to that.
 
Back
Top