Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
File search
Message
De
02/01/1998 10:41:32
Cetin Basoz
Engineerica Inc.
Izmir, Turquie
 
 
À
02/01/1998 00:40:44
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Divers
Thread ID:
00068852
Message ID:
00068904
Vues:
39
>I have to write an application that searches for a
>specific file whose name I always know, but can reside
>anyware on the drive (often out of the vfp search
>path). What steps can I take to reliably find it?
>
>TIA
>Chris

Hi Chris,
Here is an old code for this. You should develop it to execute faster I think.
lparameters startdir, cfilename
start=seconds()
set talk off
mtopdir=sys(5)+curdir()
create cursor filelist (directory m,filename c(40), filesize i,filedate d,fileattr c(5))
set defa to (startdir)
PUBLIC ARRAY DIRLIST[1,2]
=GETSUBDIRS()
for ix=1 to alen(dirlist,1)
	=checkfile(dirlist[ix,1],cFileName)
endfor
set defa to (mtopdir)
? seconds()-start, alen(dirlist,1)
browse
return

***********************************************************************
* GETSUBDIRS : COLLECT SUBDIRECTORY NAMES INTO ARRAY <DIRLIST>
***********************************************************************
FUNCTION GETSUBDIRS
dirlist[1,1]=curdir()
apos=ascan(dirlist,.f.)
do while apos>0
	crow=asubscript(dirlist,apos,1)
	set default to trim(dirlist[crow,1])
	dirlist[crow,2]=.t.
	=putsubs()
	apos=ascan(dirlist,.f.)
enddo

***********************************************************************
* PUTSUBS : COLLECT SUBDIRECTORY NAMES OF CURRENT DIRECTORY 
*			INTO PUBLIC ARRAY <DIRLIST>
***********************************************************************
function putsubs
mcurdir=sys(5)+curdir()
subcnt=adir(dirs,"","D")
if subcnt>0
	for dirc=1 to subcnt
		if dirs[dirc,1]="."
			loop
		endif	
		dimension dirlist[alen(dirlist,1)+1,2]
		dirlist[alen(dirlist,1),1]=mcurdir+dirs[dirc,1]
	endfor
endif

***************************************************************************
* CHECKFILE : CHECK cFileName in cDirectory and insert into cursor filelist
***************************************************************************
function checkfile
lparameters cDirectory,cFileName
private aDirectory, ix
nFileCnt = adir(aDirectory,cDirectory+iif(right(cDirectory,1)#"\","\","")+cFilename)
if  nFilecnt > 0
	for ix=1 to alen(aDirectory,1)
		insert into filelist values (cDirectory,aDirectory[ix,1],aDirectory[ix,2],aDirectory[ix,3],aDirectory[ix,4])
	endfor
endif

Çetin Basöz

The way to Go
Flutter - For mobile, web and desktop.
World's most advanced open source relational database.
.Net for foxheads - Blog (main)
FoxSharp - Blog (mirror)
Welcome to FoxyClasses

LinqPad - C#,VB,F#,SQL,eSQL ... scratchpad
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform