Environment: Tested on Windows NT (SP5) with Visual C++ 6 (SP4)
What is it ?
A “Del [Path]*.*” /sxyz” NT utility.
I had to write a “Empty Directory” utility on WIN NT, without using Shell. So I wrote this function. I think it can be usefull
for programmers who don’t have time to learn Files under NT.
This is a recursive function which delete all the directories and files inside the directory sent as a parameter (sPath).
The Parameter ‘sPath’ has to be a full path name without “\” at the end.
So is it !
With this call, you can empty every directory also important one.
I am not responsible for deleting important data with my Code !
TRUE if the directory exists,
FALSE if it not.
// Include this line before your code where you call
// this function !
BOOL EmptyDirectory(CString &sPath);
// This is a recursive function which empty a directory path
// of its files and call itself if necessary to delete
BOOL EmptyDirectory(CString &sPath)
CString sWildCard = sPath + “\*.*”;
BOOL bWorking = finder.FindFile(sWildCard);
bFound = bWorking;
bWorking = finder.FindNextFile();
if (finder.IsDots()) continue;
CString s = finder.GetFilePath();
_unlink( finder.GetFilePath() );