Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Delete a directory and all its files
Message
From
06/11/2004 13:00:19
Jon Neale
Bond International Software
Wootton Bassett, United Kingdom
 
 
To
06/11/2004 12:43:12
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 6
OS:
Windows '98
Database:
Visual FoxPro
Miscellaneous
Thread ID:
00958848
Message ID:
00958856
Views:
13
Hi Luigi,

I can never get the links to other threads to work. Heres the code it isnt mine so i cant take the credit.
set safety off
mypath=GETDIR()
IF EMPTY(mypath)
    RETURN .T.
ENDIF
=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 fileerror
    delete file (mypath+"\*.*")
    rd (mypath)
    on error
return(.t.)

PROCEDURE FILEERROR
    myError = 1
    RETURN
HTH

Jon
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform