C++问题,请都进来看一下吧!
如何判断一个文件夹是否存在?
如果存在则删除,不存在则显示"这个文件不存在"
[解决办法]
判断目录是否存在:
CFilefind finder; static const tchar szfiletofind[] = _t("c:\\growsys"); if (finder.findfile(szfiletofind)) { finder.findnextfile(); //afxmessagebox(finder.getfilename()); if (!finder.isdirectory()) { afxmessagebox("c:\\growsys是文件"); } else { afxmessagebox("c:\\growsys是文件夹"); } } else { afxmessagebox("没有发现c:\\growsys"); }
[解决办法]
#include <iostream>#include <direct.h>using namespace std;int main(){ if(_rmdir("D:\\my")==-1) cout<<"目录不存在!"<<endl; return 0;}