C++有关问题,请都进来看一下吧
C++问题,请都进来看一下吧!
如何判断一个文件夹是否存在?
如果存在则删除,不存在则显示"这个文件不存在"
------解决方案--------------------
判断目录是否存在:
如何判断一个文件夹是否存在?
如果存在则删除,不存在则显示"这个文件不存在"
------解决方案--------------------
判断目录是否存在:
- C/C++ code
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"); }
------解决方案--------------------
- C/C++ code
#include <iostream> #include <direct.h> using namespace std; int main() { if(_rmdir("D:\\my")==-1) cout<<"目录不存在!"<<endl; return 0; }