Sometimes it becomes necessary to find out the directory where the current executing assembly is running. Among several ways to do the task , the following code–snippet can be employed to return the absolute location of the loaded file that contains the manifest:
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Beware that Assembly.Location property returns the location of the assembly file after it is shadow-copied. In addition , if it is dynamically loaded using Load method, it returns empty string .
As stated in the comments below, if you are interested in retrieving the location of the assembly before it is shadow-copied or loaded, use Assembly.CodeBase property instead. Please note that, it is the location specified originally while stating the AssemblyName.