c++判断文件或目录是否存在

#include<sys/stat.h>

#include<fstream>

#include<string>

#include<stdio.h>

#include<stdlib.h>

#include<vector>

#include<io.h>

#include<iostream>

bool IsFileGood(string strFileName, book bFile)

{

if(bFile) \\文件

{

ifstream Ifn(strFileName.c_str());

bool bRet = Ifn.good();

Ifn.close();

return bRet;

}

else \\目录

{

return (access(strFileName.c_str(), 0) != -1)

}

}

相关推荐
岁忧7 小时前
(nice!!!)(LeetCode 面试经典 150 题 ) 30. 串联所有单词的子串 (哈希表+字符串+滑动窗口)
java·c++·leetcode·面试·go·散列表
SunkingYang7 小时前
MFC/C++语言怎么比较CString类型最后一个字符
c++·mfc·cstring·子串·最后一个字符·比较
界面开发小八哥7 小时前
MFC扩展库BCGControlBar Pro v36.2新版亮点:可视化设计器升级
c++·mfc·bcg·界面控件·ui开发
R-G-B7 小时前
【15】MFC入门到精通——MFC弹窗提示 MFC关闭对话框 弹窗提示 MFC按键触发 弹窗提示
c++·mfc·mfc弹窗提示·mfc关闭弹窗提示·mfc按键触发 弹窗提示
十秒耿直拆包选手7 小时前
Qt:QCustomPlot类介绍
c++·qt·qcustomplot
珊瑚里的鱼7 小时前
第十三讲 | map和set的使用
开发语言·c++·笔记·visualstudio·visual studio
逑之7 小时前
C++笔记1:命名空间,缺省参数,引用等
开发语言·c++·笔记
L_autinue_Star8 小时前
从0到1实现Shell!Linux进程程序替换详解
linux·运维·服务器·c++·chrome
lixzest8 小时前
C++ 中两个类之间的通信方式
开发语言·c++