Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Deleting a directory and subdir
Message
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
00871627
Message ID:
00871891
Vues:
13
Hi Steve,

Here is a recursive method we use to simulate a DELTREE. You can pass .T. to the 2nd parameters to save the structure and delete only the files. It could (and should but we're all too lazy here :P ) be modified to use a TRY/CATCH in case of file access denied problems, and parameters should be added to be able to pass the folder skeleton and the file skeleton. But so simulate a DELTREE, it works. Be aware that use it for small to medium folder structure, I don't know how the memory issue will go if you have a huge huge folder structure with a lot of files.

Hope this helps!
Sylvain
FUNCTION FDelete
LPARAMETERS tcPath, tlKeep
PRIVATE i,laDir,laFile

FOR i = 1 TO ADIR(laDir,m.tcPath+"*.*","D")
	IF !laDir(m.i,1) $ ".,.." AND "D" $ laDir(m.i,5)
		=FDelete(ADDBS(m.tcPath+laDir(m.i,1)),m.tlKeep)
	ENDIF
ENDFOR

FOR i = 1 TO ADIR(laFile,m.tcPath+"*.*")
	DELETE FILE (m.tcPath+laFile(m.i,1))
ENDFOR

IF DIRECTORY(m.tcPath) AND !m.tlKeep
	RMDIR (m.tcPath)
ENDIF

RETURN
>Hi,
>Is there a way with vfp 6.0 to delete a directory and all subdirectories including
>files therein with a function or program?
>Thanks
>Steve Elster
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform