在c#代码中,如何实现判断一个指定文件file(注:我可以判断是否存在指定文件夹),是否存在?????????????

解决方案 »

  1.   

    文件:System.IO.FileInfo
    文件夹:System.IO.Directory
      

  2.   

    if( System.Io.File.Exits(文件路径及文件名) )

       //存在
    }
    else
    {
       //不存在
    }
      

  3.   

    System.IO.File.Exists(string path) //库自带函数 确定指定的文件是否存在 返回值(bool型),true为存在,false为否
      

  4.   

    if(System.IO.File.Exists(System.IO.Directory.GetCurrentDirectory() + @"\PLN_Config.ini"))
    {
    System.Text.StringBuilder AnnounceTime = new System.Text.StringBuilder(1024);
    GetPrivateProfileString("initTime","AnnounceTime","error",AnnounceTime,AnnounceTime.MaxCapacity,System.IO.Directory.GetCurrentDirectory()+@"\Config.ini");
    this.ultraCalendarCombo1.Value = System.DateTime.Parse(AnnounceTime.ToString())+new System.TimeSpan(0,0,1,0,0);
    }
      

  5.   

    贴多了,这一句就可以了.
    if(System.IO.File.Exists(System.IO.Directory.GetCurrentDirectory() + @"\PLN_Config.ini"))
    {
    }