你的位置:phpArticle  >  高级技术讨论  >  windows编程  >  如何判断文件是否存在
 

如何判断文件是否存在

日期:2006-06-13 13:32:12  点击:  作者:  来源:
发表评论 | 查看评论 | 加入收藏 | 推荐给朋友 | 打印本文 | 字体:[ ]

复制内容到剪贴板
代码:
#include <sys/stat.h>
#include <io.h>
bool FileExist(const char* FileName)
{
struct stat my_stat;
return (stat(FileName, &my_stat) == 0);
}
bool IsDirectory(const char* FileName)
{
struct stat my_stat;
if (stat(FileName, &my_stat) != 0) return false;
return ((my_stat.st_mode & S_IFDIR) != 0);
}
 
责任编辑:niuboy