get the executable name witin a console exe
-
I need to get the .exe name within the same application running... I've tried to use Application.ExecutablePath but the whole Application class doesn't work inside my console application. So how can i do?
Hi Sasuko, You can use Reflection to get the file name of the exe file. You have two options:
System.Reflection.Assembly.GetExecutingAssembly().Location
returns the path to the file the actual code is in. So if you put this line in a class library, it will give you the .dll file.System.Reflection.Assembly.GetEntryAssembly().Location
returns the path to the file which was first run to start the application. So whether you put this in your console app, or a class library it references, it will always return the path to the .exe. Hope this helps Philip Cole