Compartir a través de


Filer.dll

Located in the Visual FoxPro \Tools\Filer directory, Filer.dll is a base component that provides a file and text search engine without a user interface. You can distribute Filer.dll and its companion files, Filer.ico, Filer.scx, and Filer.sct, with your Visual FoxPro run-time applications.

Note

These files are unsupported. Technical support is not available for problems you encounter when using these files.

For more information about using Filer.dll, see the following sections:

  • Creating a Filer Object

  • Creating a User Interface for Filer

  • Using Filer Object Properties and Methods

Creating a Filer Object

You can use Filer.dll to programmatically create an instance of Filer to search for and manipulate files without any input from a user. Filer.dll also includes support for searching text strings in files and opening multiple files for editing.

Filer.dll is a COM object and supports Automation. Therefore, you can create an instance of Filer for other Automation servers such as Microsoft Visual Basic and Microsoft Excel.

To create an instance of the Filer search engine

  • Include the following line of code to create an instance of Filer.

    oMyFiler = CREATEOBJECT('Filer.FileUtil')
    

To create an instance of Filer for other Automation servers, you can use similar syntax.

Creating a User Interface for Filer

Visual FoxPro includes a sample form, Filer.scx (and Filer.sct), to show how you can create a user interface for Filer. When you run the form, the File Finder dialog box appears, and Filer is added to the Visual FoxPro Tools menu for the current Visual FoxPro session.

To run the Filer form

  • Run the DO FORM command as follows:

    DO FORM (HOME(1) + 'Tools\Filer\Filer.scx')
    

For more information, see File Finder Dialog Box.

To view the code behind or modify the Filer form

  • Run the MODIFY FORM command as follows:

    MODIFY FORM (HOME(1) + 'Tools\Filer\Filer.scx')
    

Using Filer Object Properties and Methods

The Filer object has properties and methods that you can use, for example, to specify file search conditions and run a file search.

When running a file search using the Filer method, Find, a Files collection object is created. The Files collection object has properties that you can use to determine information about the files that match search conditions. The Files collection object also has methods you can use to open or delete matching files.

The following example demonstrates how you can search for and open text files from Visual FoxPro.

oMyFiler = CREATEOBJECT('Filer.FileUtil')
oMyFiler.SearchPath = HOME() && Point search path to home directory.
oMyFiler.FileExpression = '*.TXT' && Specify text file search.
oMyFiler.Find(0) && Search and discard last collection

FOR nFileCount = 1 TO oMyFiler.Files.Count
   oMyFiler.Files.Item(nFileCount).Edit && Open files.
ENDFOR

Filer Object Properties

The following table describes the properties associated with the Filer object.

Property

Data Type

Description

SearchPath

C

The folder from which the search starts. Universal naming conventions (UNC) are supported. Read/write.

FileExpression

C

The file search mask that can include multiple masks separated by semicolons (;). For example, the file search mask *.scx; *.sct specifies to search for all files with the extensions .scx and .sct. The default file search mask is *.*. Read/write.

SubFolder

N

A numeric value that specifies if a recursive search is performed from the folder specified with the SearchPath property. If SubFolder is 0, the file search is performed only in the folder specified with the SearchPath property. If SubFolder is 1, the file search is performed in the folder specified with the SearchPath property and all its subfolders. Note that the Filer ignores System folders. The default value is 0. Read/write.

SearchText1

C

A text string to search for in the files that match the file search mask specified by the FileExpression property. The default value is the empty string. Read/write.

SearchText2

C

An additional text string to search for in the files that match the file search mask specified by the FileExpression property. Ignored if SearchText1 contains the empty string. The default value is the empty string. Read/write.

SearchText3

C

An additional text string to search for in the files that match the file search mask specified by the FileExpression property. Ignored if SearchText1 and SearchText2 contain the empty string. The default value is the empty string. Read/write.

IgnoreCase

N

A numeric value specifying whether or not case is ignored for text in the text strings specified in SearchText1, SearchText2, and SearchText3. If IgnoreCase is 0, case isn't ignored (upper- and lower-case are significant). If IgnoreCase is 1, case is ignored. The default value is 1. Read/write.

WholeWords

N

A numeric value specifying whether or not the text in the text strings specified in SearchText1, SearchText2, and SearchText3 must match whole words for the search to be successful. If WholeWords is 0, the text in the text strings do not have to match whole words for the search to be successful. If WholeWords is 1, the text in the text strings must match whole words for the search to be successful. The default value is 0. Read/write.

SearchAnd

N

A numeric value specifying whether or not all the text in the text strings specified in SearchText1, SearchText2, and SearchText3 must match for the search to be successful. If SearchAnd is 0, the search is successful if any of the text in the text strings matches. If SearchAnd is 1, the search is successful only if all of the text in the text strings matches. The default value is 0. Read/write.

Editor

C

The editor in which files are opened with the Files collection Open method. Ignored if the IsHostedByFox property is 1. The default editor is Notepad. Read/write.

IsHostedByFox

N

A numeric value indicating the client that instantiated Filer.dll. If IsHostedByFox is 1, the client is Visual FoxPro, and the Visual FoxPro editor is used to open files. If IsHostedByFox is 0, the client is an application other than Visual FoxPro, and the editor used to open files is specified by the Editor property. The default value is 1 in Visual FoxPro. Read/write.

SortBy

N

A numeric value that specifies the order in which the Files collection is sorted. The following table lists the values for the SortBy property and the order in which the files are sorted. 0   No order 1   Path and file name 2   File name 3   File extension 4   File size 5   File last write date 6   File last access date 7   File creation date 8   File attributes The default value is 1. Read/write.

SortDirection

N

A numeric value that specifies if the Files collection is sorted in ascending or descending order. If SortDirection is 0, the Files collection is sorted in ascending order. If SortDirection is 1, the Files collection is sorted in descending order. The default value is 0. Read/write.

Filer Object Methods

The following table describes the methods associated with the Filer object.

Method

Description

Find(nValue)

A method that performs the file search and creates a Files collection. The Find method contains a numeric value indicating the number files in the Files collection.

nValue is a numeric value that specifies if Files collections from previous searches are discarded. If nValue is 0, the Files collections from previous searches are discarded. If nValue is 1, the Files collection created by the current search is appended to the previous searches.

Note that nValue is not optional.

Files Collection Objects

The following table describes the object references associated with the Files collection.

Object

Description

Item(nValue)

An object reference to a file in the Files collection. nValue is an index to a file in the Files collection. nValue begins at 1, and continues to the number of files in the Files collection. You can use the Count property, described below, to determine the number of files in the Files collection.

Files Collection Properties

The following table describes the properties associated with the Files collection.

Property

Data Type

Description

Count

N

Contains the number of files in the Files collection. Read-only.

Name

C

The name of the file, excluding the path. Read-only.

Size

N

The size of the file in bytes. Read-only.

SizeHigh

N

The high 4 bytes of the file size if the file size is greater than 4 gigabytes. Read-only.

Attr

N

The Windows file attributes for a file. The following is a list of numeric values for typical file attributes. 0   No attributes set 1   Read-Only 2   Hidden 4   System 32   Archived The value of Attr can be the sum of several file attributes. For example, if Attr is 7 (1+2+4), the file is a read-only, hidden system file. For more information about the other file attributes for which Attr returns values, see the GetFileAttributes function described in the Microsoft Developer's Network library. Read/write.

DateTime

N

The time stamp assigned by Windows to a file when it is created. The integer portion of the time stamp is the number of days since 12/30/1899, and the remainder is the fractional remainder of the day from which you can determine the time when the file was created. The Filer form, Filer.scx, contains a user-defined method called GetTime that demonstrates how you can determine the date and time a file was created from the DateTime property. Read-only.

LastAccessTime

N

The time stamp assigned by Windows to a file when it is was last accessed. Read-only.

LastWriteTime

N

The time stamp assigned by Windows to a file when it is was last written to. Read-only.

AlternateName

C

The short name of the file if the file name is longer than the MS-DOS® 8.3 character naming convention. Read-only.

Path

C

The full path to file. Read-only.

Files Collection Methods

The following table describes the methods associated with the Files collection.

Method

Description

Edit

Opens the specified file for editing. If the IsHostedByFox property is 1 (the default for Visual FoxPro), the file is opened in the Visual FoxPro editor. If the IsHostedByFox property is 0, the file is opened in the editor specified with the Editor property (NotePad by default).

Delete

Deletes the specified file from disk. The file isn't placed in the Recycling Bin.

See Also

Reference

CREATEOBJECT( ) Function

DO FORM Command

MODIFY FORM Command

Other Resources

Utility Programs

Development Productivity Tools

Automation and COM Servers

Distributing Applications