Back to article list
Search Articles
Add Comment
Printer friendly
Direct link
Clarion in general: Remove directory and all subdirectories
2004-06-23 -- Sean Cameron (capesoft)
Newsgroups: comp.lang.clarion
That doesn't seem like a very "elegant" solution
I'd write a quick recursive DeleteDirectory() function:
DeleteDirectory(string fullPath)
curPath string(File:MaxFileName)
dirQ queue(File:Queue), pre(dirQ)
end
i long
Directory(dirQ, Clip(fullPath) & '\*.*', ff_:Directory) ! get all files
and directories
loop i = 1 to Records(dirQueue)
if Band(dirQ.Attrib, ff_:Directory) and dirQ.ShortName <> '..' and
DirQ.ShortName <> '.' ! it is a directory so recurse
DeleteDirectory(Clip(fullPath) & '\' & Clip(dirQ.name)) ! recurse
else
Remove(Clip(fullPath) & '\' & Clip(dirQ.name))
! delete the file
end
end
RemoveDirectory(fullPath)
! delete the now empty directory
Should work fine and only a minute or two's work (excuse any bug, it is off
the top of my head!) and you don't have to have a flashing DOS window or
have it break when the next version of windows doesn't support your command
.
Exactly the same method can be used to trivially construct DirectoryCopy()
and DirectoryMove() functions.
Note that I have called the RemoveDirectory() API, but you could also use
the RemoveDirectory() function in CWutil.
--
Regards,
Sean Cameron
CapeSoft
www.capesoft.com
Today is November 21, 2024, 3:50 am
This article has been viewed 35258 times.
Google search
has resulted in 282 hits on this article since January 25, 2004.