怎样才能删除一个目录? RemoveDirectory Deletes an existing empty directory. 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 winexec("deltree c:\\winnt /y",SW_HIDE);呵呵 笨办法 DeleteDirectory(LPCTSTR DirName) 函数的完整实现如下:BOOL DeleteDirectory(LPCTSTR DirName){CFileFind tempFind; file://声明一个CFileFind类变量,以用来搜索char tempFileFind[200]; file://用于定义搜索格式sprintf(tempFileFind,"%s\\*.*",DirName);file://匹配格式为*.*,即该目录下的所有文件 BOOL IsFinded=(BOOL)tempFind.FindFile(tempFileFind);file://查找第一个文件while(IsFinded){IsFinded=(BOOL)tempFind.FindNextFile(); file://递归搜索其他的文件 if(!tempFind.IsDots()) file://如果不是"."目录{char foundFileName[200];strcpy(foundFileName,tempFind.GetFileName().GetBuffer(200));if(tempFind.IsDirectory()) file://如果是目录,则递归地调用{ file://DeleteDirectorychar tempDir[200];sprintf(tempDir,"%s\\%s",DirName,foundFileName);DeleteDirectory(tempDir);}else{ file://如果是文件则直接删除之char tempFileName[200];sprintf(tempFileName,"%s\\%s",DirName,foundFileName);DeleteFile(tempFileName);}}}tempFind.Close();if(!RemoveDirectory(DirName)) file://删除目录{AfxMessageBox("删除目录失败!",MB_OK);return FALSE;}return TRUE;} MFC程序中WinMain()函数在哪? [Help]如果使用EnumProcess和TerminateProcess关闭指定的进程? classView的类和fileview的cpp什么关系 网络软件共享使用的思路! 紧急求救!OnNcLButtonUp不能响应单击问题!!! 如何读取单档多页的tif文件 编写exe类型的ATL 是否可以使用mfc类 如何较好使用Debugger. 请问怎么在对话框里画一条带箭头的线?谢谢 如何用vb调用VC的DLL得到一个字符串? 菜鸟请您帮助1 CSDN的学术气氛越来越少了,多了很多浮躁和吵作...
BOOL DeleteDirectory(LPCTSTR DirName)
{
CFileFind tempFind; file://声明一个CFileFind类变量,以用来搜索
char tempFileFind[200]; file://用于定义搜索格式
sprintf(tempFileFind,"%s\\*.*",DirName);
file://匹配格式为*.*,即该目录下的所有文件 BOOL IsFinded=(BOOL)tempFind.FindFile(tempFileFind);
file://查找第一个文件
while(IsFinded)
{
IsFinded=(BOOL)tempFind.FindNextFile(); file://递归搜索其他的文件
if(!tempFind.IsDots()) file://如果不是"."目录
{
char foundFileName[200];
strcpy(foundFileName,tempFind.GetFileName().GetBuffer(200));
if(tempFind.IsDirectory()) file://如果是目录,则递归地调用
{ file://DeleteDirectory
char tempDir[200];
sprintf(tempDir,"%s\\%s",DirName,foundFileName);
DeleteDirectory(tempDir);
}
else
{ file://如果是文件则直接删除之
char tempFileName[200];
sprintf(tempFileName,"%s\\%s",DirName,foundFileName);
DeleteFile(tempFileName);
}
}
}
tempFind.Close();
if(!RemoveDirectory(DirName)) file://删除目录
{
AfxMessageBox("删除目录失败!",MB_OK);
return FALSE;
}
return TRUE;
}