使用System.IO.File,要检查一个文件是否存在非常简单:
bool exist = System.IO.File.Exists(fileName); |
如果需要判断目录(文件夹)是否存在,可以使用System.IO.Directory:
bool exist = System.IO.Directory.Exists(folderName); |
博客介绍了使用System.IO进行文件和目录存在性检查的方法。使用System.IO.File可简单检查文件是否存在,若要判断目录是否存在,则可使用System.IO.Directory。
使用System.IO.File,要检查一个文件是否存在非常简单:
bool exist = System.IO.File.Exists(fileName); |
如果需要判断目录(文件夹)是否存在,可以使用System.IO.Directory:
bool exist = System.IO.Directory.Exists(folderName); |
5961
6054

被折叠的 条评论
为什么被折叠?