如题

解决方案 »

  1.   


    先用 DeleteFile删除该目录下所有文件
    然后用
    RemoveDirectory函数RemoveDirectoryThe RemoveDirectory function deletes an existing empty directory.
    BOOL RemoveDirectory(
      LPCTSTR lpPathName
    );Parameters
    lpPathName 
    [in] Pointer to a null-terminated string that specifies the path of the directory to be removed. The path must specify an empty directory, and the calling process must have delete access to the directory. 
    In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend "\\?\" to the path. For more information, see Naming a File.
    Windows Me/98/95:  This string must not exceed MAX_PATH characters.
    Return Values
    If the function succeeds, the return value is nonzero.If the function fails, the return value is zero. To get extended error information, call GetLastError.Res
    To recursively delete the files in a directory, use the SHFileOperation function.Windows Me/98/95:  RemoveDirectoryW is supported by the Microsoft Layer for Unicode. To use this, you must add certain files to your application, as outlined in Microsoft Layer for Unicode on Windows 95/98/Me Systems.Requirements
    Client: Included in Windows XP, Windows 2000 Professional, Windows NT Workstation, Windows Me, Windows 98, and Windows 95.
    Server: Included in Windows Server 2003, Windows 2000 Server, and Windows NT Server.
    Unicode: Implemented as Unicode and ANSI versions. Note that Unicode support on Windows Me/98/95 requires Microsoft Layer for Unicode.
    Header: Declared in Winbase.h; include Windows.h.
    Library: Use Kernel32.lib.
      

  2.   

    Res
    To recursively delete the files in a directory, use the SHFileOperation function.
      

  3.   

    是的,我用过SHFileOperation,这个函数功能好强的.
      

  4.   

    这个问题在FAQ上有说明了,参考:
    http://community.csdn.net/Expert/FAQ/FAQ_Index.asp?id=201809