请帮小弟我写出这段程序的头文件以及对应的函数,万分感谢了
请帮我写出这段程序的头文件以及对应的函数,万分感谢了
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;
------解决方案--------------------
CFile 有个Remove
------解决方案--------------------
The MFC class CFileFind performs local file searches :
#include <afx.h>
--------
RemoveDirectory
The RemoveDirectory function deletes an existing empty directory.
BOOL RemoveDirectory(
LPCTSTR lpPathName // pointer to directory to remove
);
Header: Declared in winbase.h.
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;
------解决方案--------------------
CFile 有个Remove
------解决方案--------------------
The MFC class CFileFind performs local file searches :
#include <afx.h>
--------
RemoveDirectory
The RemoveDirectory function deletes an existing empty directory.
BOOL RemoveDirectory(
LPCTSTR lpPathName // pointer to directory to remove
);
Header: Declared in winbase.h.