Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
My Directory Recursive Sample Code
Message
 
 
To
10/06/2005 18:12:34
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 9
OS:
Windows 2000 SP4
Miscellaneous
Thread ID:
01022342
Message ID:
01022346
Views:
14
Take a look at XDIR File #25487 and Re: Filer.dll wont show .userSettings.ini file Message #993038.

>I heavily modified some code I found from a Michael Reynolds. It works like Adir() but has full file paths for every file and every subdirectory and subdirectory file below the passed path.
>
>
>*!*this fills the passed array (1,5) with full file paths for all files and directories *!*below the
>*!*passed path as well as file attributes, array must be passed by name, the last row   *!*in the
>*!*array is blank
>
>Function Recurse
>LPARAMETERS pcDir, lcPaths
>Local lnPtr, lnFileCount, laFileList, lcDir, lcFile
>
>IF RIGHT(pcDir,1) != "\"
>	pcDir = pcDir + "\"
>ENDIF
>
>IF DIRECTORY(pcDir) = .F.
>	RETURN 1
>ENDIF
>
>Dimension laFileList(1)
>
>*Read the chosen directory.
>lnFileCount = Adir(laFileList, pcDir + '*.*', 'D')
>For lnPtr = 1 To lnFileCount
>
>	If 'D' $ laFileList(lnPtr, 5)
>		*Get directory name.
>		lcDir = laFileList(lnPtr, 1)
>
>		*Ignore current and parent directory pointers.
>		If lcDir != '.' And lcDir != '..'
>			&lcPaths(Alen(&lcPaths,1), 1) = pcDir + lcDir
>			*Expand the array one row
>			Dimension &lcPaths(Alen(&lcPaths,1) + 1, 5)
>			*Call this routine again.
>			Recurse(pcDir + lcDir, lcPaths)
>		Endif
>	Else
>	   *Get the file properties.
>            &lcPaths(Alen(&lcPaths,1), 1) = pcDir + laFileList(lnPtr,1)
>            &lcPaths(Alen(&lcPaths,1), 2) = pcDir + ALLTRIM(STR(laFileList(lnPtr,2)))
>            &lcPaths(Alen(&lcPaths,1), 3) = pcDir + DTOC(laFileList(lnPtr,3))
>            &lcPaths(Alen(&lcPaths,1), 4) = pcDir + laFileList(lnPtr,4)
>            &lcPaths(Alen(&lcPaths,1), 5) = pcDir + laFileList(lnPtr,5)
>            *Expand the array one row
>	   Dimension &lcPaths(Alen(&lcPaths,1) + 1, 5)
>	Endif
>
>ENDFOR
>	RETURN 0
>Endfunc
--sb--
Previous
Reply
Map
View

Click here to load this message in the networking platform