Megosztás a következőn keresztül:


Matcher Class

Definition

Searches the file system for files with names that match specified patterns.

public ref class Matcher
public class Matcher
type Matcher = class
Public Class Matcher
Inheritance
Matcher

Remarks

Patterns specified in AddInclude(String) and AddExclude(String) can use the following formats to match multiple files or directories.

  • Exact directory and file name.
    • one.txt
    • dir/two.txt
  • Wildcards (*) in file and directory names that represent zero to many characters not including directory separators characters.
    ValueDescription
    *.txtAll files with .txt file extension.
    *.*All files with an extension.
    *All files in top-level directory.
    .*File names beginning with '.'.
    *word*All files with 'word' in the filename.
    readme.*All files named 'readme' with any file extension.
    styles/*.cssAll files with extension '.css' in the directory 'styles/'.
    scripts/*/*All files in 'scripts/' or one level of subdirectory under 'scripts/'.
    images*/*All files in a folder with name that is or begins with 'images'.
  • Arbitrary directory depth (/**/).
    ValueDescription
    **/*All files in any subdirectory.
    dir/**/*All files in any subdirectory under 'dir/'.
    dir/All files in any subdirectory under 'dir/'.
  • Relative paths.
    ValueDescription
    ../shared/*All files in a diretory named "shared" at the sibling level to the base directory given to Execute(DirectoryInfoBase).

Constructors

Matcher()

Initializes an instance of Matcher using case-insensitive matching.

Matcher(StringComparison)

Initializes an instance of Matcher using the specified string comparison method.

Methods

AddExclude(String)

Add a file name pattern for files the matcher should exclude from the results. Patterns are relative to the root directory given when Execute(DirectoryInfoBase) is called.

Use the forward slash '/' to represent directory separator. Use '*' to represent wildcards in file and directory names. Use '**' to represent arbitrary directory depth. Use '..' to represent a parent directory.

AddInclude(String)

Add a file name pattern that the matcher should use to discover files. Patterns are relative to the root directory given when Execute(DirectoryInfoBase) is called.

Use the forward slash '/' to represent directory separator. Use '*' to represent wildcards in file and directory names. Use '**' to represent arbitrary directory depth. Use '..' to represent a parent directory.

Equals(Object)

Determines whether the specified object is equal to the current object.

(Inherited from Object)
Execute(DirectoryInfoBase)

Searches the directory specified for all files matching patterns added to this instance of Matcher.

GetHashCode()

Serves as the default hash function.

(Inherited from Object)
GetType()

Gets the Type of the current instance.

(Inherited from Object)
MemberwiseClone()

Creates a shallow copy of the current Object.

(Inherited from Object)
ToString()

Returns a string that represents the current object.

(Inherited from Object)

Extension Methods

AddExcludePatterns(Matcher, IEnumerable<String>[])

Adds multiple exclude patterns to Matcher.

AddIncludePatterns(Matcher, IEnumerable<String>[])

Adds multiple patterns to include in Matcher.

GetResultsInFullPath(Matcher, String)

Searches the specified directory for all files matching patterns added to this instance of Matcher.

Match(Matcher, IEnumerable<String>)

Matches the files passed in with the patterns in the matcher without going to disk.

Match(Matcher, String, IEnumerable<String>)

Matches the files passed in with the patterns in the matcher without going to disk.

Match(Matcher, String, String)

Matches the file passed in with the patterns in the matcher without going to disk.

Match(Matcher, String)

Matches the file passed in with the patterns in the matcher without going to disk.

Applies to