Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Subdirectories
Message
From
23/01/1999 17:05:50
 
 
General information
Forum:
Visual FoxPro
Category:
Other
Title:
Miscellaneous
Thread ID:
00179419
Message ID:
00179449
Views:
19
>Is there a way to copy a directory with all its content (subdirectories with files inclusive) without knowing the names of the subdirectories with code?
>Eduardo


Hello Eduardo!

The following function will give you back an array containing the files and dirs of the specified dir.

Function nGetDirFiles
LPARAMETER tcDirPath, taFileok, tnLevel
* gives back into array taFileok the recoursive list of files + dirs
*
* 1. col. fullpath
* 2. col. type F: file D: dir
*
* return rows of array taFileok
*
EXTERNAL array taFileok
IF type("tnLevel")='L'
tnLevel=0
DIMENSION taFileok(1,2)
taFileok(1,1)=""
taFileok(1,2)=" "
ENDIF
IF right(tcDirPath,1)#'\'
tcDirPath=tcDirPath+'\'
ENDIF
LOCAL array laFileok(1,1)
LOCAL lnFileokSzama, i, lnSize, lnNumber
lnNumber=0
lnFileokSzama=adir(laFileok,tcDirPath+"*.*","D") && get dirs and files
IF lnFileokSzama>0
* firstly the files
FOR i=1 to lnFileokSzama
IF 0=at("D",laFileok(i,5),1) && sima file
IF !empty(taFileok(1,1))
DIMENSION taFileok(alen(taFileok,1)+1,2)
ENDIF
lnNumber=lnNumber+1
taFileok(alen(taFileok,1),1)=tcDirPath+laFileok(i,1)
taFileok(alen(taFileok,1),2)='F'
ENDIF
IF alen(taFileok,1)>30000 && carefully!!
exit
endif
ENDFOR
* now the contained dirs
IF alen(taFileok,1)<30000
FOR i=1 to lnFileokSzama
IF 0#at("D",laFileok(i,5),1) && sima file
IF laFileok(i,1)#"." and laFileok(i,1)#".."
IF !empty(taFileok(1,1))
DIMENSION taFileok(alen(taFileok,1)+1,2)
ENDIF
lnNumber=lnNumber+1
taFileok(alen(taFileok,1),1)=tcDirPath+laFileok(i,1)
taFileok(alen(taFileok,1),2)='D'
IF tnLevel lnNumber=lnNumber+nGetDirFiles(tcDirPath+laFileok(i,1)+"\", @taFileok, (tnLevel+1) )
ENDIF
ENDIF
ENDIF
ENDFOR
ENDIF
ENDIF
RETURN lnNumber

BB
Previous
Reply
Map
View

Click here to load this message in the networking platform