我需要执行程序集的bin路径。你怎么得到的?我在Bin / Debug中有一个文件夹插件,我需要获取该位置
以下是获取应用程序执行路径的方法:
var path = System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
MSDN对how to determine the Executing Application's Path有完整的参考。
请注意,path
中的值将采用file:\c:\path\to\bin\folder
的形式,因此在使用路径之前,您可能需要将file:\
从前面剥离。例如。:
path = path.Substring(6);
你可以做到这一点
Assembly asm = Assembly.GetExecutingAssembly();
string path = System.IO.Path.GetDirectoryName(asm.Location);
这就是我过去常常要完成的事情:
System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, System.AppDomain.CurrentDomain.RelativeSearchPath ?? "");
var assemblyPath = Assembly.GetExecutingAssembly().CodeBase;
Path.GetDirectoryName(Application.ExecutablePath)
例如。值:
C:\Projects\ConsoleApplication1\bin\Debug