我想在C#中测试一个包含文件路径的字符串,以确定是否存在该文件(类似于-ePerl或os.path.exists()Python中的测试).
Dan*_*ngs 288
使用:
File.Exists(path)
Run Code Online (Sandbox Code Playgroud)
MSDN:http://msdn.microsoft.com/en-us/library/system.io.file.exists.aspx
编辑:在System.IO中
Pet*_*ann 52
using System.IO;
if (File.Exists(path))
{
Console.WriteLine("file exists");
}
Run Code Online (Sandbox Code Playgroud)