Copy File c:\test\*.* to d:\backup\*.*
will copy all files in the test directory but does not get the subdirectories. Is there an eazy way to get them all?
wjwjr
I've always liked this question... so this time I thought I would try and write some code to handle this. I create an array using a recursive function that will contain all of the files (full path) within the specified directory (including all sub directories). Cut-N-Paste the code below into a prg file and run it from within VFP. It's easiest to see the array from the debugger.
Dimension aryFiles(1)
=GetAllFiles(GETDIR(), @aryFiles)
SET STEP ON
FUNCTION GetAllFiles(cDirectory, aryParam)
*!* EXTERNAL ARRAY aryAllFiles
LOCAL ARRAY aryTemp(1,5)
LOCAL nCount, nMax, nLen, cFile
SET DEFAULT TO (cDirectory)
=ADIR(aryTemp, "*.*","AHRSD",1)
nMax = ALEN(aryTemp,1)
FOR nCount = 1 TO nMax
cFile = ALLTRIM(aryTemp(nCount,1))
IF !(cFile == "." AND !(cFile == ".."
IF "D" $ aryTemp(nCount,5)
See my FAQ
A cursor to collect all files in a specific directory
faq184-3102
This can be made to collect all recursive also...
=doDirFiles(cmyDir,.t.) for recursive
=doDirFiles(cmyDir,.f.) for root files only
we can make that as a function..
*********************************************************
** Author : Ramani (Subramanian.G)
** FoxAcc Software / Winners Software
** ramani_g@yahoo.com
** Type : Freeware with reservation to Copyrights
** Warranty : Nothing implied or explicit
** Last modified : 31 January, 2003
*********************************************************
** The following uses Filer.DLL and
** extracts all files in a directory as a cursor.
*********************************************************
FUNCTION doDirFiles
PARAMETERS tcDir, tlRecurse
IF VARTYPE(tcDir) # "C"
tcDir = "C:\"
ENDIF
IF VARTYPE(tlRecurse) = "U"
tlRecurse = .t.
ENDIF
May be we have provided only a solution which could lead you to achieve what you want. But the follwoing is a simpler code and a much easier alternative.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.