>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
View the map of this thread
View the map of this thread starting from this message only
View all messages of this thread
View all messages of this thread starting from this message only