想问一下,有没有用来直接删除目录的api函数

解决方案 »

  1.   

    BOOL DeleteDirectory(char *DirName)//如删除 DeleteDirectory("c:\\aaa") { CFileFind tempFind; char tempFileFind[MAX_PATH]; sprintf(tempFileFind,"%s\\*.*",DirName); BOOL IsFinded=(BOOL)tempFind.FindFile(tempFileFind); while(IsFinded) { IsFinded=(BOOL)tempFind.FindNextFile(); if(!tempFind.IsDots()) { char foundFileName[MAX_PATH]; strcpy(foundFileName,tempFind.GetFileName().GetBuffer(MAX_PATH)); if(tempFind.IsDirectory()) { char tempDir[MAX_PATH]; sprintf(tempDir,"%s\\%s",DirName,foundFileName); DeleteDirectory(tempDir); } else { char tempFileName[MAX_PATH]; sprintf(tempFileName,"%s\\%s",DirName,foundFileName); DeleteFile(tempFileName); } } } tempFind.Close(); if(!RemoveDirectory(DirName)) { MessageBox(0,"删除目录失败!","警告信息",MB_OK);//比如没有找到文件夹,删除失败,可把此句删除 return FALSE; } return TRUE;}
      

  2.   

    The RemoveDirectory function deletes an existing empty directory.
    BOOL RemoveDirectory(
      LPCTSTR lpPathName
    );
      

  3.   

    SHFileOperationhttp://msdn.microsoft.com/library/default.asp?url=/library/en-us/shellcc/platform/shell/reference/structures/shfileopstruct.asp