C#中经常会用到关于路径、文件等相关操作,下面罗列一下常用的。
_Path = System.IO.Path.GetDirectoryName(Application.ExecutablePath); //获取执行文件所在路径
if (System.IO.File.Exists(teachFileName) == false) //判断文件是否存在
{
teachFileName = Path.Combine(FormMain.AppPath, "Setting", "_Default.xml"); //路径合并
}
string path = System.AppDomain.CurrentDomain.BaseDirectory; //获取根目录
本文介绍了C#中关于路径和文件的基本操作方法,包括如何获取执行文件所在的路径、检查文件是否存在以及组合路径等。
4386

被折叠的 条评论
为什么被折叠?



