Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What's the difference between AppDomain.CurrentDomain.BaseDirectory and Application.ExecutablePath in practice?

Tags:

c#

.net

appdomain

According to the MSDN, the BaseDirectory is where an AppDomain will look for DLLs to load, while ExecutablePath will provide the path to the original executable file (including file name). I know that one has the file name and the other does not. I know that if I create a new AppDomain I can give it a different path. But removing the file name from ExecutablePath and assuming I'm only using one AppDomain, in practice, what is the difference between those two paths? Will they always be the same (again, assuming only one AppDomain)? Is there an instance when they would be different?

like image 760
Jon Turner Avatar asked Oct 06 '08 17:10

Jon Turner


People also ask

What is AppDomain CurrentDomain BaseDirectory?

AppDomain. CurrentDomain. BaseDirectory returns the directory from where the current application domain was loaded.

What is base directory in C#?

The base directory is the path on your system that corresponds to the path where your application will be installed.


1 Answers

Think of something like ASP.NET where your code is hosted inside another process. The BaseDirectory is going to be where your code lives, but the ExecutablePath is probably some dll in system32.

like image 162
Orion Edwards Avatar answered Oct 05 '22 13:10

Orion Edwards