Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Best Way to Delete a Directory and all its contents?
Message
From
03/07/2009 15:59:50
 
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Miscellaneous
Thread ID:
00843644
Message ID:
01409985
Views:
87
That's probably why that message was dated 2003. :o) That was 6 years ago...


>Interesting, but I don't think effective with many files in the directory.
>
>>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"
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform