Is there a way to get the path for the assembly in which the current code resides? I do not want the path of the calling assembly, just the one containing the code.
<
Same as John's answer, but a slightly less verbose extension method.
public static string GetDirectoryPath(this Assembly assembly)
{
string filePath = new Uri(assembly.CodeBase).LocalPath;
return Path.GetDirectoryName(filePath);
}
Now you can do:
var localDir = Assembly.GetExecutingAssembly().GetDirectoryPath();
or if you prefer:
var localDir = typeof(DaoTests).Assembly.GetDirectoryPath();