FileContains

Top  Previous  Next

 

The NotFileContains 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:

 

NotFileContains:[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:

 

CurrentCulture

Compare strings using culture-sensitive sort rules and the current culture.

 

CurrentCultureIgnoreCase

Compare strings using culture-sensitive sort rules, the current culture, and ignoring the case of the strings being compared.

 

InvariantCulture

Compare strings using culture-sensitive sort rules and the invariant culture.

 

InvariantCultureIgnoreCase

Compare strings using culture-sensitive sort rules, the invariant culture, and ignoring the case of the strings being compared.

 

Ordinal

Compare strings using ordinal (binary) sort rules.

 

OrdinalIgnoreCase

Compare strings using ordinal (binary) sort rules and ignoring the case of the strings being compared.

 

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.

lamp 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:NotFileContains:"c:\Test Text.txt","Test text",Remark:"Yes",Remark:"No"

 

See Also: FileContains FileIsNewer FileIsOlder FileExists DirectoryExists NotDirectoryExists