读书人

C++有关问题,请都进来看一下吧

发布时间: 2012-02-04 15:43:08 作者: rapoo

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;} 

读书人网 >C++

热点推荐