日期:2014-05-18  浏览次数:20770 次

如何判断文件夹下是否有某个文件。
string configPath = Directory.GetCurrentDirectory().ToString(); 
取到了D:\AA\BB
如何判断BB下是否有A.TXT的文件。

------解决方案--------------------
System.IO.File.Exists() 确定指定的文件是否存在。
------解决方案--------------------
System.IO.File.Exists(fileName);
------解决方案--------------------
System.IO.File.Exists() 确定指定的文件是否存在。 

正解

if(File.Exists("D:\\AA\\BB\\A.Txt"))
{
Response.Write("文件存在!");
}
else
{
Response.Write("文件不存在!");
}