Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Erik Gomez
  Where is Erik Gomez?
 Victorias City, Negros Occidental
 Philippines
 Erik Gomez
 To: Le Thạnh Hai
  Where is Le Thạnh Hai?
 Hanoi
 Vietnam
 Le Thạnh Hai
 Tags
Subject: RE: how to list all files and directories.. sample
Thread ID: 21998 Message ID: 22182 # Views: 12 # Ratings: 0
Version: Visual FoxPro 6 Category: General VFP Topics
Date: Friday, April 11, 2003 4:09:27 AM         
   


> > > Hello.
> > > Please show me how to list all files and directories on a drive (or the other directory) by useing VFP or Win32API.
> > > thanks!
> >
> > Hi there,
> >
> > see the function ADIR(). The help explains how to use it.
> >
> > Regards
> >
> > Gaetan
> Hi,
> Thank you for your suggestion
hi,

i got the code recently from a tip in VFP Advisor magazine. i can't remember the name of the person who submitted the tip. anyway, i modified the code to suit my needs. check out the code below.

Clear All
lcFolderPath = GetDir('','Select Folder','',64,.f.)
If Empty(lcFolderPath)
	lcFolderPath = FullPath(Curdir())
EndIf

lcCurrPath = Fullpath(Curdir())
Cd (lcFolderPath)
lcFile = Recursion()
Cd (lcCurrPath)

lcMess = 'Files lookup completed.' + Chr(13) +;
	'List of files is located at : ' + Chr(13) + lcFile 
Messagebox(lcMess,64,lcFolderPath)

Procedure Recursion
If !Used('curFiles')
	Create Cursor curFiles (cFname c(200))
Endif
Local lnCount, laDirs[1], lcFile, i
lcFile = Addbs(Sys(2023)) + 'Files.txt'
lcPath = Addbs(Fullpath(Curdir()))
lnCount = Adir(laDirs,"*.*","D")
For i = 1 To lnCount
	If (laDirs[i,1] <> ".") And ("D" $ laDirs[i,5])
		Cd Alltrim(laDirs[i,1])
		lnCnt = Adir(laFiles,'*.*','')
		For lnX = 1 To lnCnt
			If !("D" $ laFiles[lnX,5])
				m.cFname = Addbs(Fullpath(Curdir())) +;
					laFiles[lnX,1]
				Wait Window 'Reading : ' + m.cFname;
					nowait
				Insert Into curFiles From Memvar
			Endif
		Next
		Do Recursion
		Cd ..
	Endif
Next
Select curFiles
Copy To (lcFile) Type Sdf
Return lcFile
Endproc



to the guy who wrote the recursion procedure thanks, it was really a great help... sorry i can't remember your name. once again thanks... you know who your are and i hope you don't mind that i modified your code.

hope this helps,
Erik Gomez
www.foxite.com - The Home of The Visual FoxPro Experts
Long Live www.foxite.com

COMPLETE THREAD

how to list all files and directories on a drive ( Posted by Le Thạnh Hai @ 4/7/2003 11:21:08 AM
RE: how to list all files and directories on a ... Posted by Gaetan Doger de Speville @ 4/7/2003 11:36:19 AM
RE: how to list all files and directories on a ... Posted by Le Thạnh Hai @ 4/8/2003 4:39:26 AM
RE: how to list all files and directories.. sample Posted by Erik Gomez @ 4/11/2003 4:09:27 AM
sample code correction Posted by Erik Gomez @ 4/11/2003 4:17:16 AM