[ACCEPTED]-Get the startup path in a vb.net console exe-io

Accepted answer
Score: 19

You could try

System.AppDomain.CurrentDomain.BaseDirectory

which would work for most cases.

0

Score: 4

EDIT: @KiwiBastard's answer is the correct 3 method:

System.AppDomain.CurrentDomain.BaseDirectory

Add a reference to System.Reflection and use

Assembly.GetExecutingAssembly().Location

EDIT: Depending 2 where you intend getting the startup path, this 1 might be more appropriate:

Assembly.GetEntryAssembly().Location
Score: 3

You can get the startup path without reflection 1 by using:

IO.Path.GetDirectoryName(Diagnostics.Process.GetCurrentProcess().MainModule.FileName)

More Related questions