好像File类下面有个类似于FileExist字样的方法,可能名字不对,你可以找找看

解决方案 »

  1.   

    using System;
    using System.IO;string path = @"c:\temp\MyTest.txt";if (File.Exists(path))
    {………………}
      

  2.   

    使用System.IO命名空间的File类
    using System.IO;
    if (File.Exists(@"C:\temp\aaa.ini"))
    {
    }

    if (File.Exists("C:\\temp\\aaa.ini"))
    {
    }
      

  3.   

    try
    {
    string str=@"c:\test";
    string str1=@"aaa.ini";
    //目录是否存在
    if(!Directory.Exists(str))
    {
    return;
    }
    //文件是否存在
    if(File.Exists(str+"\\"+str1))
    {
    //……
    }
    }
    catch
    {
    btnReport.Visible=false;
    return null;
    }
      

  4.   

    谢谢大家!
    我想再问一个其它问题!
    在一个Button点击事件下如何实现自动重新进入该程序?
    我这样写:
    Application.Exit();
    Application.Run();
    报错说要用RunDialog()可是我改过来又报错说:RunDialog()受保护级别限制!