次の方法で共有


Filer.dll

Filer.dll is a component version of the Filer desk accessory, available in previous versions of Microsoft Visual FoxPro (versions 3.0b and earlier). Filer.dll supports the most popular features of the Filer, including support for searching files for text strings and opening multiple files for editing.

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

Filer.dll is a base component that provides the file and text search engine, but doesn't include a user interface. For example, you can programmatically create an instance of the Filer and search for and manipulate files without any input from a user. However, a Visual FoxPro form, Filer.scx (and Filer.sct), is provided to demonstrate how you can create a user interface for Filer.dll.

The following command will create an instance of the non-visual Filer search engine in Visual FoxPro. The syntax for other Automation servers is similar.

oMyFiler = CREATEOBJECT('Filer.FileUtil')

Once the Filer object is instantiated, you can specify file search conditions with the Filer properties, and then execute the file search with the Find( ) method. The Find method creates a Files collection object with its own set of properties that make it possible for you to determine information about the files that match the search conditions. There are also methods for the Files collection object that make it possible for you to open or delete the matching files.

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

*** Instantiate the Filer object
oMyFiler = CREATEOBJECT('Filer.FileUtil')

oMyFiler.SearchPath = HOME() && Home directory
oMyFiler.FileExpression = '*.TXT' && Text file search

oMyFiler.Find(0) && Search, discard last collection

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

Distribution

You can distribute Filer.dll and its companion files, filer.ico, filer.scx, and filer.sct, with your distributed Visual FoxPro runtime applications.

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

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.

Running Filer.scx

A sample form, Filer.scx, is included to demonstrate how you can create a user interface in Visual FoxPro for Filer.dll. To run the Filer form, use the DO FORM command as follows:

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

When you run the Filer form, a Filer item is added to the Visual FoxPro Tools menu, and the item remains in the menu during the current Visual FoxPro session. Choose the Filer item from the Tools menu to run the Filer again.

Issue the following command to open the Filer form to view the code behind the interface or to modify the form:

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

See Also

VFP8R.DLL Run-Time Library | VFP8T.DLL Run-Time Library | COMPOBJ( ) Function | DO FORM Command