FileContains |
Top Previous Next |
The FileContains condition returns true if a text file contains specified text.
Command Syntax
The Command syntax is the command name, followed by a colon, then the fully qualified path and file name to check, then the text to search for:
FileContains:[FileToCheck],[TextToSearchFor],[StringComparison]
Parameters:
FileToCheck: The fully qualified path and file name of the text file to check TextToSearchFor: The text for which to search StringComparison: A string representing a member of the StringComparison enumeration:
FileToCheck and TextToSearchFor parameters are compulsory, the StringComparison parameter is optional. If provided, the value must be one of the following:
If no StringComparison parameter is provided, the default StringComparison.Ordinal will be used.
If any required parameter is missing or invalid an error will be thrown. All parameters must be surrounded by quotation marks if one or more spaces are included. It is good practice to include the quotation marks in any case, so that it reduces the risk of error when writing scripts. IMPORTANT: This command works only with Text based files. Because of the need to to go through each file at the base level to accurately detect whether there are any matches, with excessively large files this command can be slow and/or use a lot of memory. Example:
If:FileContains:"c:\Test Text.txt","Test text",Remark:"Yes",Remark:"No"
See Also: FileIsNewer FileIsOlder FileExists DirectoryExists NotDirectoryExists NotFileContains |