日期:2014-05-17 浏览次数:20863 次
/// <summary>
/// 获取Assembly的运行路径
/// </summary>
/// <returns></returns>
public static string GetAssemblyPath()
{
try
{
string _CodeBase = System.Reflection.Assembly.GetExecutingAssembly().CodeBase;
_CodeBase = _CodeBase.Substring(8, _CodeBase.Length - 8); // 8是 file:// 的长度
string[] arrSection = _CodeBase.Split(new char[] { '/' });
string _FolderPath = "";
for (int i = 0; i < arrSection.Length - 1; i++)
{
_FolderPath += arrSection[i] + "/";
}
return _FolderPath.Replace("/", @"\");
}
catch
{
return null;
}
}