/// <summary>
/// 获得项目的根路径
/// </summary>
/// <returns></returns>
public string GetProjectRootPath()
{
    string rootPath = "";
    string BaseDirectoryPath = AppDomain.CurrentDomain.BaseDirectory; // F:\WAF Projects\mjl\code\HomeDecorationPSD\HomeDecorationPSD\bin\Debug\
    // 向上回退三级,才能到项目的根目录
    rootPath = BaseDirectoryPath.Substring(0, BaseDirectoryPath.LastIndexOf("\\")); // 第一个\是转义符,所以要写两个
    rootPath = rootPath.Substring(0, rootPath.LastIndexOf("\\"));
    rootPath = rootPath.Substring(0, rootPath.LastIndexOf("\\")); // F:\WAF Projects\mjl\code\HomeDecorationPSD\HomeDecorationPSD\
    return rootPath;
}

http://bbs.csdn.net/topics/390349037

相关文章:

  • 2021-07-05
  • 2022-12-23
  • 2021-11-29
  • 2021-11-29
猜你喜欢
  • 2021-12-01
  • 2021-12-21
  • 2022-01-24
  • 2021-11-23
相关资源
相似解决方案