C#中取程序运行目录和某文件所在目录的方法

// 程序运行路径,带\。
public static string GetPath()
{
    string str = System.Windows.Forms.Application.ExecutablePath;
    return str.Substring(0, str.LastIndexOf('\\') + 1);
}
// 获得指定文件的路径,带\。
public static string GetPath(string str)
{
    return str.Substring(0, str.LastIndexOf('\\') + 1);
}

本文版权遵循 CC BY-NC-SA 4.0发布,转载需附带本文链接。

当前页阅读量为: