我如何获得Bin Path? [英] How do I get Bin Path?
本文介绍了我如何获得Bin Path?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我需要执行程序集的bin路径.你怎么得到的?我在Bin/Debug中有一个文件夹Plugins,我需要获取位置
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
推荐答案
以下是获取应用程序执行路径的方法:
Here is how you get the execution path of the application:
var path = System.IO.Path.GetDirectoryName(
System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase);
MSDN关于如何确定执行应用程序路径的完整参考.
请注意, path
中的值将采用 file:\ c:\ path \ to \ bin \ folder
的形式,因此在使用路径之前,您可以需要将 file:\
剥离掉.例如:
Note that the value in path
will be in the form of file:\c:\path\to\bin\folder
, so before using the path you may need to strip the file:\
off the front. E.g.:
path = path.Substring(6);
这篇关于我如何获得Bin Path?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文