# Include <iostream>
# Include <string. h>
# Include <windows. h>
Using namespace STD;
Bool deldir (char * szdir)
{
Win32_find_data findfiledata;
Handle hfind;
Char szdirname [300] = "/0 ";
Char szfilename [300] = "/0 ";
Sprintf (szdirname, "% S // *. *", szdir );
Hfind = findfirstfile (szdirname, & findfiledata );
If (hfind = invalid_handle_value)
{
Return false;
}
Do
{
If (strcmp (findfiledata. cfilename ,".")! = 0) & (strcmp (findfiledata. cfilename ,"..")! = 0 ))
{
Sprintf (szfilename, "% S // % s", szdir, findfiledata. cfilename );
DWORD dwattr = getfileattributes (szfilename );
If (dwattr & file_attribute_directory)
{
Deldir (szfilename );
}
Else
{
Deletefile (szfilename );
}
}
} While (findnextfile (hfind, & findfiledata ));
Findclose (hfind );
Char sztrace [32];
Bool Bret = removedirectory (szdir );
If (! Bret)
{
Sprintf (sztrace, "% lu-", getlasterror ());
Outputdebugstring (sztrace );
}
Outputdebugstring (szdir );
Outputdebugstring ("/N ");
Return true;
}
Int main ()
{
Deldir ("D: // test // testdel ");
Getchar ();
}