Previous Document Next Document
CorelScriptTools.FindFirstFolder

Function FindFirstFolder(SearchCriteria As String, Attributes As Long) As String

Member of CorelScriptTools

You can use the FindFirstFolder and FindNextFolder functions to assemble or perform an operation on a list of files, folders, or both. The FindFirstFolder function is used to locate the first file or first folder in a folder that meets a specified search criteria. The FindNextFolder function is used to locate the next file or next folder that meets the specified search criteria set by the FindFirstFolder. The FindNextFolder function must be used in conjunction with the FindFirstFolder function.

Parameter
Description
SearchCriteria
Specifies the files or folders for which to search. You can include wild-card characters (* or ?).
Attributes
Specifies the type of files or folders you want to use. Use the OR operator to specify multiple file and folder types:
1 = read-only
2 = hidden
4 = system
16 = folders (if not specified, files are used)
32 = archive
128 = normal (not read-only, hidden, system or archive file or folder)
256 = temporary
2048 = compressed

  • Specifying folder in the attributes parameter (16) by itself does not specify a type of folder. You must use another parameter along with 16 to specify a folder type.

In the following code example, the first loop fills an array (DIRARR) with the names of the normal folders in the D:\Corel\Ventura\Samples folder. The second loop searches the folders in the Samples folder for any file with the extension VP. Any found VP file has its name added to the FILESARR array and has its name displayed in a message box.

dim Dcount%, Fcount% 'creates 2 integer variables 
dim FilesArr$(100), DirArr$(100) 'creates 2 string arrays 
rem LOOP #1 
REM Find all directories in the Samples folder 
Dcount = 1 
DirArr(Dcount) = FINDFIRSTFOLDER("D:\Corel\Ventura\Samples\*", 16 
or 128) 
WHILE (DirArr(Dcount) <> "") 
 MESSAGE DirArr(Dcount) 
 IF DirArr(Dcount) <> "." AND DirArr(Dcount) <> ".." THEN Dcount = 
Dcount + 1 
 DirArr(Dcount) = FINDNEXTFOLDER() 
WEND 
rem LOOP #2 
REM Find all *.vp files in each Directory found in earlier loop 
DIM i% 
Fcount = 1 
FOR i% = 1 TO Dcount-1 
 FilesArr(Fcount) = FINDFIRSTFOLDER("D:\Corel\Ventura\Samples\" + 
DirArr(i%) + "\*.vp", 1 or 2 or 4 or 32 or 128) 
 WHILE (FilesArr(Fcount) <> "" ) 
 MESSAGE DirArr(i%) & CHR(13) & FilesArr(Fcount) 
  Fcount = Fcount + 1 
  FilesArr(Fcount) = FINDNEXTFOLDER() 
 WEND 
NEXT i% 

The following statement in the first loop is used to remove the current (.) folder and parent (..) folder from being sent to the DIRARR array:

IF DirArr(Dcount) <> "." AND DirArr(Dcount) <> ".." THEN Dcount = 
Dcount + 1 

Previous Document Next Document Back to Top

Copyright 2007 Corel Corporation. All rights reserved.