当前位置:首页>网络学院>程序开发>Visual C++教程>文章内容
广告位出租 广告位出租

删除非空目录

[ 来源: | 作者: | 时间:2007-06-26 | 收藏 | 推荐 ] 【

广告位出租


#include "stdafx.h"

bool DeleteDirectory(char* DirName)

{
CFileFind tempFind;
char tempFileFind[200] ;

sprintf(tempFileFind,"%s\\*.*",DirName);
BOOL IsFinded = tempFind.FindFile(tempFileFind);
while (IsFinded)
{

IsFinded = tempFind.FindNextFile();

if (!tempFind.IsDots())
{
char foundFileName[200];
strcpy(foundFileName,tempFind.GetFileName().GetBuffer(200));

if (tempFind.IsDirectory())
{
char tempDir[200];
sprintf(tempDir,"%s\\%s",DirName,foundFileName);
DeleteDirectory(tempDir);
}
else
{
char tempFileName[200];
sprintf(tempFileName,"%s\\%s",DirName,foundFileName);
DeleteFile(tempFileName);
}
}
}
tempFind.Close();
if(!RemoveDirectory(DirName))
{
MessageBox(0,"é?3yê§°ü","ê§°ü",MB_OK);
return FALSE;
}

return TRUE;

}

void main()
{
DeleteDirectory("d:\\222");
}

(阅读次数:

返回顶部
 
广告位出租

网友评论

[以下评论为网友观点,不代表本站。请自觉遵守互联网相关政策法规,所有连带责任均有评论者自负。]
[不超过250字]