如何删除一个文件夹下所以的目录和文件? 如何删除一个文件夹下所以的目录和文件? 解决方案 » 免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货 http://community.csdn.net/Expert/topic/2958/2958809.xml?temp=.540188 参数DirName为要删除的目录名,必须为绝对路径名,如“c:\\temp"。BOOL DeleteDirectory(char *DirName){ CFileFind tempFind; char tempFileFind[200]; sprintf(tempFileFind,"%s\\*.*",DirName); BOOL IsFinded=(BOOL)tempFind.FindFile(tempFileFind); while(IsFinded) { IsFinded=(BOOL)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(!RemovwDirctory(DirName)) { MessageBox(0,"删除目录失败!","警告信息",MK_OK); return FALSE; } return TRUE;} 关于InitSock()函数 不同风格的界面是如何用GDI画的? 熟悉C++Builder的兄弟过来看一下 用VC,如何将UNICODE字符串转化为ANSI字符串,要源代码。 线程退出时绑定的socket端口号不释放 VC下不能编译通过DLL的DEBUG版,但能编译RELEASE版.为什么? 【求助】 如何才能频繁绘图,但使窗口不闪烁 RichEdit操作问题 img文件如何打开? _NextObjectMapEntry 找不到。 MSDN 坏了 ,在哪里还可以 查啊!! 请教大侠一个基本的小问题,在线等待,急啊
BOOL DeleteDirectory(char *DirName)
{
CFileFind tempFind;
char tempFileFind[200];
sprintf(tempFileFind,"%s\\*.*",DirName);
BOOL IsFinded=(BOOL)tempFind.FindFile(tempFileFind);
while(IsFinded)
{
IsFinded=(BOOL)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(!RemovwDirctory(DirName))
{
MessageBox(0,"删除目录失败!","警告信息",MK_OK);
return FALSE;
}
return TRUE;
}