CFindFiles:new


The new method constructs a new instance of a CFindFiles object. The CFindFiles class iterates over files in a folder, fetching the names of files matching a template. Three different constructor overloads are available to create a new CFindFiles and initialize the properties. The folder name used must be a complete path specification.

Syntax

F = CFindFiles:new()

F = CFindFiles:new( sFolder )

F = CFindFiles:new( sFolder, sTemplate )

where

 

    F is the new CFindFiles object.

    The first form, with no arguments passed, creates a new object. You then must call Open before file searching can be performed.

    The second form uses the string sFolder to specify the name of the folder. This automatically opens file searching inside the named folder. The folder name is a complete path specification. Unless later changed by the Open method, the filename template is initialized to "*.*".

    The third form specifies both the initial folder sFolder and the search string template, sTemplate. This creates a new CFindFiles object for the specified folder using the specified file name template.

  

Three overloads are provided for this method. If you use the default constructor with no arguments, then the Open method must be called to set the folder where searching is to be done. If the folder and optional template are specified in the constructor, then the Open method need not be called before calling Next.

Example

The following script lists files inside the folder specified by the string sFolder:

 

F = CFindFiles:new( sFolder )

-- Create a new CFindFiles object

while F:Next() do

-- Iterate to the next file

  Printf("%s\r\n", F:GetPath() )

-- list the current path name

end

 

F:Close()

-- finished with this object

Related Topics

delete

CFindFiles class