Jump to content

Enumerating exe file location in vb.net.


Guest xmob

Recommended Posts

This is bugging me. Is there any way to enumerate the location of the currently running exe in vb.net?

All I want to do is open a file that's in the same folder as the exe, but

Dim stream_reader As New IO.StreamReader("file to open")

doesn't seem to work. Putting the full path does, but that's no good when a user can install the application in a choice of locations.

Link to comment
Share on other sites

Guest Mike Wagstaff

I use this code to determine the app's working directory:

Public strAppPath = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly(

.GetName().CodeBase)

You'll need to add a trailing slash to reference a file. For example, to assign the working directory + filename of a file called "stadium.jpg" to a string...

Private strStadiumImagePath As String = strAppPath & "stadium.jpg"

Link to comment
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.