Guest xmob Posted September 24, 2004 Report Posted September 24, 2004 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.
Guest Mike Wagstaff Posted September 25, 2004 Report Posted September 25, 2004 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"
Guest xmob Posted September 25, 2004 Report Posted September 25, 2004 Nice one! That worked a treat. Thank you very much.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now