Sometimes, I do it the LONG way completely within VFP:
mypath="C:\tracy"
=getfolders(mypath)
IF !DIRECTORY(mypath)
RETURN .T.
ELSE
MESSAGEBOX("could not delete the directory: "+mypath)
ENDIF
function GetFolders
parameters mypath
local lstfiles[1], dirnum,i
? mypath
dirnum = adir(lstfiles,mypath+"\*.*","D")
for i = 3 to dirnum
if "D"$lstfiles(i,5)
GetFolders(mypath+"\"+lstfiles(i,1))
endif
next
on error do fileerr
delete file (mypath+"\*.*")
rd (mypath)
on error
return(.t.)
PROCEDURE FILEERR
myError = 1
RETURN
Just another option as you asked.
>Hi,
>
>We've got a web app based on West Wind Web Connection. Many clients will be using the same app. Every once in a while we upgrade our app - and that may include new fields. We are going to upgrade the tables by backing up the clients table folder. (renameing it to tables.bak) Then we create a new tables folder. We have a client called "setup" which is just blank, updated tables. We copy the tables, etc., in the clients tables folder. Then we append the data from the old structures into the new updated tables and populate the new fields.
>
>Before we can backup the old tables we need to remove the old backup. (if it exists)
>
>I need to write code to delete an directory and all its contents. (including sub folders) It has to be able to run without any user intervention.
>
>I've looked at two possible ways to do this.
>1. The SHFileOperation API function. It says that you may see "windows file operation animations" Does that mean you have answer "yes" to delete the folder?
>2. Use windows file scripting object. I found some example code of this on the west wind messageboard that looks fairly easy. I know its dangerous to have this enabled, but we already use the file scripting object elsewhere in the code...
>
>Just wondering what your thoughts on this were...Or if there is another way that I don't know about.
>
>Thanks,
>Chris
.·*´¨)
.·`TCH
(..·*
010000110101001101101000011000010111001001110000010011110111001001000010011101010111001101110100
"When the debate is lost, slander becomes the tool of the loser." - Socrates
Vita contingit, Vive cum eo. (Life Happens, Live With it.)
"Life is not measured by the number of breaths we take, but by the moments that take our breath away." -- author unknown
"De omnibus dubitandum"