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);
}

题外话:我帮你整理了包括 AI 写作、绘画、视频(自媒体制作)零门槛 AI 课程 + 国内可直接顺畅使用的软件。想让自己快速用上 AI 工具来降本增效,辅助工作和生活?限时报名

当前页阅读量为: