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发布,转载需附带本文链接。
猜你喜欢
- 使用 OleDB 实现远程多线程数据库访问(C#, Access 数据库)
- 快速排序示例 (语言:C#)
- 使用C#尝试编写百度之星程序设计大赛的题目(一)
- 我也谈 C# 的执行效率到底有多高
- C#实现的一个小程序(计算任意几个数的平均数)
当前页阅读量为: