C#判断文件存在需要从几方面入手,这里介绍的三种方法,主要是实现硬盘上的判断。判断文件存在,是进行文件操作的基础。

命名空间:System.IO
C#判断文件存在***种方法:
- File.Exists(Application.StartupPath + "\\AlarmSet.txt");
C#判断文件存在第二种方法:
- System.IO.DirectoryInfo info = new System.IO.DirectoryInfo(Application.StartupPath + "\\AlarmSet.txt");
- MessageBox.Show(info.Exists.ToString());
C#判断文件存在第三种方法:
- File.Create(Application.StartupPath + "\\AlarmSet.txt");//创建该文件
【编辑推荐】

售后响应及时
7×24小时客服热线
数据备份
更安全、更高效、更稳定
价格公道精准
项目经理精准报价不弄虚作假
合作无风险
重合同讲信誉,无效全额退款