Bamix_O

I have created a small program that acts as a launcher to a series of other files.

Buttons and menu items point to other files/apps that run separately.

Everything works well as long as the installation is to the PC hard drive of C:\

However, if installed to D:\ or the like then the links from the buttons and menus fail to locate the file that needs to be run.

An example of the string from one button is below:

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

System.Diagnostics.Process.Start("C:\Program Files\Sample\Sample-Index.pdf")

End Sub

The installation by default is to the *:\Program Files folder where *: is where the O/S is installed. However, if this is not C:\ then the program fails to run the files required.

Is there a way to set a wildcard character so that another drive letter is accepted

I am quite new to this and am happy with what I have been able to accomplish, but if other users have other than a C:\ drive specified then it all falls over. Any help would be appreciated.



Re: Visual Basic Express Edition Accomodating different drive letters

Derek Smyth

Hi,

There is a enumeration you can use with the Enviroment object to get the location of special folders like MyDocument, Program Files, etc. This will point to the location regardless of the drive.

Code Snippet

Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)

So your code will be like this...

Code Snippet

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim progFiles as String = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles)

System.Diagnostics.Process.Start(progFiles & "\Sample\Sample-Index.pdf")

End Sub






Re: Visual Basic Express Edition Accomodating different drive letters

Bamix_O

Derek,

Thanks for your help, the code you included solved the problem for me.

Apologies for delayed reply. I had to first re-build the files set attached to my app and then find a PC to test it on.

Cheers !