/// <summary>
/// 获取当前DLL的目录
/// </summary>
/// <param name="removeBackslash">结尾不带反斜杠,默认为true</param>
/// <returns></returns>
public static string GetDllPath(bool removeBackslash = true)
{
//获得程序集的位置,file:///+文件位置
string codeBase = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
//去掉前面的file……
codeBase = codeBase.Substring(8, codeBase.Length - 8);
//全部把斜杠换成反斜杠,统一
codeBase = codeBase.Replace("/", "\\");
//去掉DLL文件的名字
int index = codeBase.LastIndexOf('\\');
codeBase = codeBase.Remove(index);
if (removeBackslash)
{
return codeBase;
}
else
{
return codeBase + "\\";
}
}
07-23
128
05-06
1316
“相关推荐”对你有帮助么?
-
非常没帮助
-
没帮助
-
一般
-
有帮助
-
非常有帮助
提交