Copyright©
Kambiz R. Khojasteh. All rights reserved.
Get future component updates from http://www.delphiarea.com.
Delphi
3 |
Delphi
4 |
Delphi
5 |
Delphi
6 |
Delphi
7 |
DESCRIPTION
TFindFile is
a non-visual component, which could be used for locating files
or folders in the file system and directory tree with an extensive set of
options. TFindFile locates files or folders by name, location, size, creation
date and time, last modification date and time, last access date and time,
or content of the file. In addition, the search process can be done in a separated
thread.
PROPERTIES
- Criteria:
TSearchCriteria
Contains the search criteria.
- Files:
TFileCriteria
Contains file and folder criteria.
-
Filename: String
Specifies the target filename masks separated by semicolon.
-
Location: String
Determines the target folders separated by semicolon.
- Included:
TStringList
Contains list of target file paths, which
filename part of the paths can contain wildcards. You may use this
property alternative to or besides Filename and Location
properties.
-
Excluded: TStringList
Contains list of files that should be excluded from the search
result. You can use wildcards for Drive and filename.
Example:
*.txt |
|
Ignores
all text files in any folder and drive |
C:\*.txt |
|
Ignores
all text files in root of drive C: |
?:\*.txt |
|
Ignores
all text files in root of any drive |
C:lib\*.txt |
|
Ignores
all text files in lib subfolder of any folder of drive C: |
lib\*.txt |
|
Ignores all text files in lib subfolder of any folder of any
drive |
C:\lib\*.txt |
|
Ignores all text files in lib subfolder of root of drive C: |
*:\lib\*.txt |
|
Ignores
all text files in lib subfolder of root of any drive
|
- Subfolders:
Boolean
If set to true, subfolders of the target folders
specified in Location and Included properties will be included
in the search. Alternatively, you may use < (less than) and > (greater
than) symbols in the beginning of a folder to bypass this property. When
the name of a folder begins with < (less than) character, regardless
of the value of Subfolders property, the component never search
in the subfolders of the folder. Vice versa, if the name of a folder begins
with > (greater than) character, subfolders of the folder always will
be included in the search.
- Attribute:
TAttributeCriteria
Contains file attributes criteria.
- Attributes:
TFileAttributes
TFileAttributes = set of (ffArchive, ffReadonly,
ffHidden, ffSystem, ffDirectory)
Determines the desired attributes for the target file(s). Alternatively,
you may use Flags property.
To
search for file(s) with only normal attribute, set Attributes property
to empty set.
ffArchive |
|
Archive
files are acceptable |
ffReadonly |
|
Read-only
files are acceptable |
ffHidden |
|
Hidden
files are acceptable |
ffSystem |
|
System
files are acceptable |
ffDirectory |
|
Directories
are acceptable |
- Flags:
Integer
Determines the desired attributes for the target file(s) as bitwise.
Alternatively,
you can use Attributes property.
- ExactMatch:
Boolean
If set to true, file will be accepted if its attributes are exactly
same as the attributes specified in Attributes or Flags
properties. When this property is set to false, the target file should
have one of specified attributes to be accepted.
Example:
Attributes
:= [ffReadonly, ffHidden]; |
|
ExactMatch
:= False; |
{
TFindFile locates for files by Read-only OR Hidden attribute
bit set. } |
ExactMatch
:= True; |
{
TFindFile locates for files by Read-only AND Hidden attribute
bit set. } |
- Size: TSizeCriteria
Contains file size criteria.
- Min:
DWORD
Determines the lower range of the file size. Set this property to
zero if you do not need this criteria.
- Max:
DWORD
Determines the upper range of the file size. Set this property to
zero if you do not need this criteria.
- TimeStamp:
TDateTimeCriteria
Contains file date and time criteria.
- CreatedAfter:
TDateTime
Determines the lower range of the file creation date and time. To ignore
lower date criteria, set date part to zero and to ignore lower time criteria,
set time part to zero.
-
CreatedBefore: TDateTime
Determines the upper range of the file creation date and time. To ignore
upper date criteria, set date part to zero and to ignore upper time criteria,
set time part to zero.
- ModifiedAfter:
TDateTime
Determines the lower range of the file last modified date and time. To
ignore lower date criteria, set date part to zero and to ignore lower
time criteria, set time part to zero.
- ModifiedBefore:
TDateTime
Determines the upper range of the file last modified date and time. To
ignore upper date criteria, set date part to zero and to ignore upper
time criteria, set time part to zero.
- AccessedAfter:
TDateTime
Determines the lower range of the file last accessed date and time. To
ignore lower date criteria, set date part to zero and to ignore lower
time criteria, set time part to zero.
- AccessedBefore:
TDateTime
Determines the upper range of the file last accessed date and time. To
ignore upper date criteria, set date part to zero and to ignore upper
time criteria, set time part to zero.
- Content:
TContentCriteria
Contains criteria about the file(s) content.
- Phrase:
String
Specifies the text that should be located in
the content of the file(s). Set this property to empty if you do not need
this option.
- IgnoreCase:
Boolean
If set to true, the component performs a case insensitive search to locate
the phrase inside the file.
- Aborted:
Boolean (Read-only)
When is true, indicates that the last search has been aborted.
- Busy: Boolean
(Read-only)
When is true a search is running and it is not finished yet.
- Threaded:
Boolean
If set to true, the component a separated thread for its process.
- ThreadPriority:
TThreadPriority
Determines priority of the thread when component is in threaded mode.
METHODS
- procedure
Execute
Starts the search process.
- procedure
Abort
Aborts the search and sets the aborted property to true. Calling Abort
method does not mean that it halts the search immediately. You have to use
OnSearchFinish event to know exactly when the search is stopped.
EVENTS
- OnFileMatch:
TFileMatchEvent
TFileMatchEvent = procedure (Sender: TObject; const Folder: String;
const FileInfo: TSearchRec) of object
This event will be triggered when a file matches with the search criteria.
"Folder" specifies the location of the file and "FileInfo"
contains the file information details (Name, Size, Time, Attr, and...).
- OnFolderChange:
TFolderChangeEvent
TFolderChangeEvent = procedure (Sender: TObject; const Folder: String; var
IgnoreFolder: Boolean) of object
This event helps you to monitor the current search location and will
be triggered when component begins to search in a new folder. To bypass a
folder, set "IgnoreFolder" to True.
- OnSearchBegin:
TNotifyEvent
Actually, when Execute method is called, the component prepares the
search criteria and after that begins the search. This event is just triggered
when the search process is about to begin.
- OnSearchFinish:
TNotifyEvent
This event is triggered when search is finished. Search can be finished because
of either completion or calling Abort method..
- OnSearchAbort:
TNotifyEvent
This event is just triggered after calling Abort method. Usually, there
is a short delay between calling Abort and stopping the process, especially
when component is working in threaded mode.
HISTORY
LICENSE
TFindFile component
is freeware. You may copy component's files AS LONG AS YOU COPY ALL OF THEM.
If you want to change the source code in order to improve the component's
features, performance, etc. please send me the new source code so that I can
have a look at it. The changed source code should contain descriptions what
you have changed, and of course your name. The only thing you MAY NOT CHANGE
is the ORIGINAL COPYRIGHT INFORMATION.
DISCLAIMER
TFindFile is
provided "AS IS" without any warranty of any kind, either express
or implied. The entire risk as to the quality and performance of the software
is with you. The author is NOT liable for any DAMAGES resulting from the use
and misuse of the component, especially he is NOT liable for DAMAGES that
were caused BY ANY VERSION WHICH HAS NOT BEEN PROGRAMMED BY THE AUTHOR HIMSELF.