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.
    string codeBase = Assembly.GetExecutingAssembly().CodeBase;
    UriBuilder uri = new UriBuilder(codeBase);
    string path = Uri.UnescapeDataString(uri.Path);
    var assemblyPath = Path.GetDirectoryName(path);

No comments:

Post a Comment