How to get the path/directory for the current assembly?

Niladri.Biswas
Posted by Niladri.Biswas under C# category on | Points: 40 | Views : 2468
Solution 1:

var path = AppDomain.CurrentDomain.BaseDirectory;


Solution 2:


var fullCurrentAssemblyPath = System.Reflection.Assembly.GetExecutingAssembly().Location;
var path = Path.GetDirectoryName(fullCurrentAssemblyPath);


Solution 3:



var codeBase = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
var uri = new UriBuilder(codeBase);
var path = Path.GetDirectoryName(Uri.UnescapeDataString(uri.Path));



Solution 4:



var filePath = new Uri(System.Reflection.Assembly.GetExecutingAssembly().CodeBase).LocalPath;
var path = Path.GetDirectoryName(filePath);


Solution 5:



var path = Environment.CurrentDirectory;


Hope this helps

Comments or Responses

Login to post response