We all know that the MS-DOS command "rd [dirname]" doesn't work on notempty directories.
Same with the API function "RemoveDirectory".
But MS-DOS "rd /s/q [dirname]" does it.
I checked for an API function which does it too. Can't find one.
Is there a possibility to remove a notempty directory without deleting the files before?
I can do it this way...
"
fOpen TCHAR 'open',0
fDatei TCHAR 'deldir.bat',0
INVOKE ShellExecute,NULL,offset fOpen,offset fDatei,NULL,NULL,SW_SHOWNORMAL
"
Does the job, but it is not very satisfying.
You would normally remove (delete) the contents of the directory first.
Hello clamicun,
Here is an example :
include \masm32\include\masm32rt.inc
.data
directory db 'test',0
.data?
shfs SHFILEOPSTRUCT <?>
.code
start:
mov edx,OFFSET shfs
mov SHFILEOPSTRUCT.hwnd[edx],0
mov SHFILEOPSTRUCT.wFunc[edx],FO_DELETE
mov SHFILEOPSTRUCT.pFrom[edx],OFFSET directory
mov SHFILEOPSTRUCT.pTo[edx],0
mov SHFILEOPSTRUCT.fFlags[edx],FOF_NOCONFIRMATION or FOF_SILENT
invoke SHFileOperation,ADDR shfs
invoke ExitProcess,0
END start
vortex,
yes - it works fine. Combine this with "Browse4Folder" and you have a very dangerous tool.
i think the FOF_ALLOWUNDO flag will send it to the recycle bin, if desired