Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Copying files and reading directories
Message
 
 
General information
Forum:
Visual FoxPro
Category:
Windows API functions
Miscellaneous
Thread ID:
00617463
Message ID:
00617511
Views:
46
This message has been marked as the solution to the initial question of the thread.
>I have two questions:
>
>1. On Nadya's suggestion, I'm looking at copying files using the API instead of COPY FILE. I'm trying to get Ed's example for SHFileOperation to work, but can't find the file ClsHeap. It says it's in the files section, but I can't find it. Does anyone know where it is?

File #9482
>
>2. In the future, I'm considering trying to speed up reading the files from the hard drive into a cursor. I'm wondering if there's any API function that would help with that. I didn't see anything when scanning through the functions, but I admit I haven't done a thourough search, yet. I just thought I'd ask as long as I was asking about that file.
>
>Thanks,
>
>Michelle
********************************************************************
*  Description.......: GetAllFiles - builds a list of all files in start directory and subdirectories
*  Calling Samples...: ?GetAllFiles('\Redp\Appl','SCX')
*  Parameter List....: pcStartDir, pcFileExt
*  Created by........: Ed Rauh
*  Modified by.......: Nadya Nosonovsky 10/18/2000 11:18:39 AM
********************************************************************
* Scripting.FileSystemObject example of recursive file list build - Ed Rauh
lparameters pcStartDir, pcFileExt
* pcStartDir - top directory to start from
* pcFileExt - only files with this extension would be added to the list,
*             leave blank for all file extensions

if empty(pcStartDir)
	pcStartDir='c:\' && Get list of files in the whole local drive
endif

local ltStartFSO
ltStartFSO = datetime()
private pnTotNumberOfFiles
pnTotNumberOfFiles=0
create cursor filesFSO ( cFilename c(100), nSize n(10), dMod d )
oFSO = createobject('Scripting.FileSystemObject')

=RecurseFolderFSO(oFSO.GetFolder(pcStartDir))
? datetime() - ltStartFSO, pnTotNumberOfFiles

index on nSize tag nSize
browse
****************************************************
function RecurseFolderFSO
lparameter toFolderObject
with toFolderObject
	for each oFile in .files
		with oFile
			if empty(pcFileExt) or justext(.path)==pcFileExt
				insert into filesFSO ;
					values (.path, .size, .DateLastModified )
				pnTotNumberOfFiles=pnTotNumberOfFiles+1
			endif
		endwith
	endfor
	for each oSubFolder in .SubFolders
		RecurseFolderFSO(oSubFolder)
	endfor
endwith
toFolderObject = null
return
OR
********************************************************************************
*  Description.......: GetAllFiles1 - builds list of all files in directory tree
*                    : uses Adir recursive call
*  Calling Samples...:
*  Parameter List....: tcStartDir, tcFileExt
*  Created by........: David Frankenbach
*  Modified by.......: 
********************************************************************************
* ADIR() method of recursively building the file list - Dave Frankenbach
lparameters tcStartDir, tcFileExt
* tcStartDir - top directory to start from
* tcFileExt - only files with this extension would be added to the list,
*             leave blank for all file extensions

* Both parameters should be character type, check it first
**************************************************************************
if empty(tcStartDir) or vartype(tcStartDir)<>'C'
	tcStartDir='c:\' && Get list of files in the whole local drive
else
	tcStartDir=addbs(tcStartDir)
endif
if empty(tcFileExt) or vartype(tcFileExt)<>'C'
	tcFileExt='' 
endif

local ltStart
ltStart = datetime()
local lnTotNumberOfFiles

create cursor curFilesADIR (cFilename c(100), nSize n(10), dMod d, Flag L)
=RecurseFolder(tcStartDir, tcFileExt) && Call recursive procedure
lnTotNumberOfFiles=reccount(curFilesAdir)
? datetime() - ltStart, lnTotNumberOfFiles

index on upper(justfname(cFileName)) tag cFileName
browse nowait

function RecurseFolder
lparameters lcDir, lcFileExt
local i , n, laFiles[1]

n = adir(laFiles, lcDir + '*.*', "shd" )

for i = 1 to n
	if (left(laFiles[i,1], 1) != '.' )
		if ("D" $ laFiles[i,5] )
			RecurseFolder(lcDir + laFiles[i,1] + "\" )
		else
			if empty(lcFileExt) or justext(laFiles[i,1])==lcFileExt
                    llFlag=.f. 
					insert into curFilesADIR ;
					values( lcDir + laFiles[i,1], laFiles[i,2], laFiles[i,3],llFlag )
			endif
		endif
	endif
endfor
return
If it's not broken, fix it until it is.


My Blog
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform