Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
FileSystemObject
Message
De
04/03/2003 07:54:43
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Titre:
FileSystemObject
Divers
Thread ID:
00760809
Message ID:
00760809
Vues:
49
I need to travers the file system to count the number of tiff files in the lowest folder
i have prg which works as long as the limit of an array is not reached
If there are more then 12000+- it breaks.

Can I use the FSO instead of adir
like
LOCAL oFSO as Scripting.FileSystemObject 
oFSO=CREATEOBJECT("Scripting.FileSystemObject")

LOCAL lcOldDir,lcRoot
lcOldDirectory = SYS(5)+SYS(2003)
lcRoot=GETDIR("c:\","Find Root  Directory","",64)

oFolder=oFSO.GetFolder(lcRoot)
?oFolder.Name

FOR EACH oItem IN oFolder.Files
	x1=oItem.Name

ENDFOR
I am stuck
* Program....:  GETDIRECTORY.PRG
* Version....:
* Author.....: Peter A. Cortiel , mailto:pcortiel@earthlink.net
* Date.......: 3/3/2003
* Notice.....: Copyright (c) 2003 ** PCS **, All Rights Reserved.
* Compiler...: Visual FoxPro 08.00.0000.2521 for Windows for Windows
* Abstract...:
* Changes....:
CLEAR
PUBLIC  nmcount
nmcount=0
CREATE CURSOR ccDIR (;
	nm i,;
	cfullname c(254),;
	cFilename c(60),;
	cType c(1) ;
	)


LOCAL lcOldDir,lcRoot
lcOldDirectory = SYS(5)+SYS(2003)


lcRoot=GETDIR("c:\","Find Root  Directory","",64)

getFolder(lcRoot)

CD (lcOldDirectory )
SELECT ccDIR
SET FILTER TO cType='F'
LOCATE
*REPORT FORM report3  PREVIEW  SUMMARY
*REPORT FORM report3  TO brenda ASCII   SUMMARY
SELECT cfullname,COUNT(*) AS COUNT  ;
	FROM ccDIR ;
	GROUP BY cfullname  ;
	ORDER BY nm WHERE RIGHT(ALLTRIM(cFilename),3)="TIF" ;
	INTO CURSOR cc1
SELECT cc1
LOCATE
_VFP.DATATOCLIP(,,3)
LOCAL oExcel AS Excel.APPLICATION
oExcel=CREATEOBJECT("Excel.Application")

oWorkBook=oExcel.workbooks.ADD()
oExcel.worksheets(1).ACTIVATE
oExcel.activesheet.PASTE

oExcel.VISIBLE=.T.
WAIT WINDOW
oExcel=""
? "DONE"

RETURN
************************
FUNCTION getFolder
	************************
	LPARAMETERS tcFoldername
	LOCAL i
	LOCAL lnNumFolders,lnNumFiles
	LOCAL oldFolder AS CHARACTER
	LOCAL ARRAY la2 [1]

	oldFolder =LOWER(ADDBS(SYS(5)+SYS(2003)))
	?tcFoldername
	CD (tcFoldername)
	TRY
		lnNumFiles=ADIR(la2,"*.*"," AHRSD")
	CATCH
		lnNumFiles=.F.
	ENDTRY
	*? "Files:"+TRANSFORM(lnNumFiles)
	IF VARTYPE(lnNumFiles)="N"
		FOR i=1 TO lnNumFiles
			IF NOT(la2[i,1]=="." OR la2[i,1]=="..")
				*?la2[i,1],la2[i,2],la2[i,3],la2[i,4],la2[i,5]
				nmcount = nmcount + 1
				IF "D"$la2[i,5]
					* ?"...."+la2[i,1]
					INSERT INTO ccDIR (nm,cfullname ,cFilename ,cType ) ;
						VALUES ;
						(nmcount,JUSTPATH(FULLPATH(la2[i,1])),la2[i,1],"D")
					getFolder(la2[i,1])
				ELSE
					*?FULLPATH(la2[i,1])
					INSERT INTO ccDIR (nm,cfullname ,cFilename ,cType ) ;
						VALUES ;
						(nmcount,JUSTPATH(FULLPATH(la2[i,1])),la2[i,1],"F")
				ENDIF
			ENDIF
		ENDFOR
	ENDIF
	CD (oldFolder )
	RETURN
Thanks

Peter
Peter Cortiel
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform