#include <afx.h>
#include <iostream.h>
BOOL DeleteDirectory(CString DirPath)
{
BOOL IsSuccess=true;
char tempFileFind[200];
sprintf(tempFileFind,"%s\\\\*.*",DirPath); // classic usage;
CFileFind findedfl;
BOOL Isfind=findedfl.FindFile(tempFileFind);
//+-----have "." indicate that directory exist;----+//
if(!Isfind)
{
cout<<"tH_s¶Ý"<<endl;
return IsSuccess=false;
}
while(Isfind)
{
//+---- attention: file include <<.>>------+//
//+----------------and <<..>>--------------+//
//+---------so can not use BOOL IsDir=findedfl.IsDirectory()---------------+//
Isfind=findedfl.FindNextFile();
CString DirName=findedfl.GetFileName();
if(!findedfl.IsDots())
{
char tempFileFind[200];
sprintf(tempFileFind,"%s\\\\%s",DirPath,DirName);
if(findedfl.IsDirectory())
{
//findedfl.Close();
BOOL IsDelete=DeleteDirectory(tempFileFind);
if(!IsDelete)
//+----sure that hava only one directory delete failed,finished the method-----------+//
return IsSuccess=false;
}
else
{
BOOL IsFlDelete=::DeleteFile(tempFileFind);
if(!IsFlDelete)
return IsSuccess=false;
}
}
}
//+-------Close() must have------------------------+//
//+------else cannot use RemoveDirectory()---------+//
findedfl.Close();
IsSuccess=::RemoveDirectory(DirPath);
return IsSuccess;
}
int main(int argc,char *args[])
{
if(argc!=2)
{
cout<<"format:d optiont"<<endl;
return 0;
}
if(!strcmp(args[1],"help"))
{
cout<<"d Directorypath"<<endl;
return 0;
}
BOOL IsDelete=::DeleteDirectory(args[1]);
if(IsDelete)
cout<<"tH_í¬÷"<<endl;
/*
+-----------------------+--------------------------------+
| cout<<__FILE__<<endl | could know the workspace path |
+-----------------------+--------------------------------+
| cout<<__LINE__<<endl | could know the code's number |
+-----------------------+--------------------------------+
*/
return 0;
}
没有合适的资源?快使用搜索试试~ 我知道了~
DeleteDirectory
共13个文件
pdb:2个
dsp:1个
dsw:1个
需积分: 35 29 下载量 45 浏览量
2008-01-30
17:33:06
上传
评论
收藏 791KB RAR 举报
温馨提示
使用vc作的一个DOS-Like程序,用到了递归<br>经过运行测试<br>vc6.0环境下编写的<br>欢迎相互学习
资源推荐
资源详情
资源评论
收起资源包目录
businese.rar (13个子文件)
businese
d.dsw 533B
d.opt 48KB
d.cpp 2KB
d.dsp 3KB
d.ncb 41KB
Debug
vc60.pdb 68KB
d.exe 96KB
d.pch 2.5MB
vc60.idb 121KB
d.ilk 68KB
d.pdb 249KB
d.obj 12KB
d.plg 815B
共 13 条
- 1
资源评论
jxc0604
- 粉丝: 2
- 资源: 6
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功