Wednesday, April 6, 2022

How to get the path of the assembly of your code is in

Here is a sample code to get the path of the assembly of your code is in.
  1. string codeBase = Assembly.GetExecutingAssembly().CodeBase;
  2. UriBuilder uri = new UriBuilder(codeBase);
  3. string path = Uri.UnescapeDataString(uri.Path);
  4. var assemblyPath = Path.GetDirectoryName(path);

No comments:

Post a Comment