I need to the the bin path of the executing assembly. How do you get it? I have a folder Plugins in the Bin/Debug and I need to get the location
kem*_*002 105
以下是获取应用程序执行路径的方法:
var path = System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
Run Code Online (Sandbox Code Playgroud)
MSDN有关于如何确定执行应用程序路径的完整参考.
请注意,值path
将采用以下形式file:\c:\path\to\bin\folder
,因此在使用路径之前,您可能需要将其file:\
从前面剥离.例如:
path = path.Substring(6);
Run Code Online (Sandbox Code Playgroud)
eto*_*bot 61
你可以做到这一点
Assembly asm = Assembly.GetExecutingAssembly();
string path = System.IO.Path.GetDirectoryName(asm.Location);
Run Code Online (Sandbox Code Playgroud)
Tho*_*eir 25
这就是我过去常常要完成的事情:
System.IO.Path.Combine(System.AppDomain.CurrentDomain.BaseDirectory, System.AppDomain.CurrentDomain.RelativeSearchPath ?? "");
Run Code Online (Sandbox Code Playgroud)
var assemblyPath = Assembly.GetExecutingAssembly().CodeBase;
Run Code Online (Sandbox Code Playgroud)
Path.GetDirectoryName(Application.ExecutablePath)
Run Code Online (Sandbox Code Playgroud)
例如.值:
C:\Projects\ConsoleApplication1\bin\Debug
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
89086 次 |
最近记录: |