You can delete a folder that is not empty.
# Include <windows. h> # Include <Tchar. h> # Include <Shellapi. h> Bool Deletedirectory (lpctstr lpszdir, Bool Norecyclebin = True ){ Int Len = _ Tcslen (lpszdir); tchar * Pszfrom = New Tchar [Len + 2 ]; _ Tcscpy (pszfrom, lpszdir); pszfrom [Len] =0 ; Pszfrom [Len + 1 ] = 0 ; Shfileopstruct fileop; fileop. hwnd = NULL; // No Status display Fileop. wfunc = fo_delete; // Delete operation Fileop. pfrom = pszfrom; // Source file name as double NULL terminated string Fileop. PTO = NULL; // No destination needed Fileop. fflags = fof_noconfirmation | fof_silent; // Do not prompt the user If (! Norecyclebin) fileop. fflags | = Fof_allowundo; fileop. fanyoperationsaborted = False; fileop. lpszprogresstitle = NULL; fileop. hnamemappings = NULL; Int Ret = shfileoperation (& Fileop); Delete [] pszfrom; Return (Ret = 0 );} Int Main () {deletedirectory ( " D: \ test " , False ); Return 0 ;}