Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I get my .NET application's path (not the path of the application that started my application)

Tags:

c#

.net

vb.net

I am having trouble getting the path of my application's executable file at runtime. This application is being started by another executable and whenever I try to use Application.ExecutablePath I get the path to that application instead of mine.

Dim aPath1 As String = Application.ExecutablePath()
Dim aPath2 As String = Application.StartupPath()

in C# it would be

string aPath1 = Application.ExecutablePath;
string aPath2 = Application.StartupPath;

Neither of these give me the path of the program in which those two lines are exectured, they only tell what program started this program.

Any help would be greatly appreciated, Thank you in advance.

like image 627
SixOThree Avatar asked Dec 01 '25 08:12

SixOThree


1 Answers

try

Assembly.GetExecutingAssembly().Location

see http://msdn.microsoft.com/en-us/library/system.reflection.assembly.location.aspx

like image 95
Yahia Avatar answered Dec 04 '25 00:12

Yahia



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!