exeContext.ExePath
I'm having a hard time trying to discover my applications path in the form load event.
In VB6 it would look something like this:
myPath = application.exePath
After discovering that My.Application.CommandLineArgs.Item(0) doesn't always contain the applications path, I moved onto the new 2.0 exeContext class. Here's the code that doesNOTcompile:
Dim appInfoAs System.Configuration.ExeContext
Dim myPath As string
'**** Attempt #1
'***** Error: Type has no constructor
appInfo = New System.Configuration.ExeContext
myPath = appInfo.ExePath
'**** Attempt #2
'***** Error: No static methods
myPath = System.Configuration.ExeContext.ExePath
'**** Attempt #3 using the command line args instead of ExeContext
'***** Error: Index out of range
'myPath = System.IO.Path.GetFullPath(My.Application.CommandLineArgs.Item(0))
Please note that you'll have to add System.Configuration as a reference to the project.
Any working examples would be great! :)
Thanks

