扫描二维码下载沐宇APP

沐宇

微信扫码使用沐宇小程序

沐宇

C#如何通过反射获取程序集路径

扬州沐宇科技
2024-06-25 00:26:33
c#

您可以使用Assembly.GetExecutingAssembly().Location来获取当前执行的程序集路径。示例如下:

using System;
using System.Reflection;

class Program
{
    static void Main()
    {
        string assemblyPath = Assembly.GetExecutingAssembly().Location;
        Console.WriteLine("Assembly Path: " + assemblyPath);
    }
}

这将打印出当前执行的程序集的路径。

扫码添加客服微信