File Search Library
LoadFileMatches Method
Example 



KellermanSoftware.FileSearchLibrary Namespace > LoadFileMatchesLogic Class : LoadFileMatches Method
Search Parameters
The directory and file name
Load file matches for a single file
Syntax
'Declaration
 
Public Function LoadFileMatches( _
   ByVal searchParms As SearchParms, _
   ByVal filePath As String _
) As LoadFileResult
'Usage
 
Dim instance As LoadFileMatchesLogic
Dim searchParms As SearchParms
Dim filePath As String
Dim value As LoadFileResult
 
value = instance.LoadFileMatches(searchParms, filePath)

Parameters

searchParms
Search Parameters
filePath
The directory and file name
Example
//Set the file to load
string filePath = @"C:\_git\Compare-Net-Objects\Compare-NET-Objects-Tests\TestClasses\Invoice.cs";
 
//What to search in the file
SearchParms searchParms = new SearchParms();
searchParms.SearchString = "FirstName";
searchParms.SearchExpressionType = SearchExpressionType.PlainText;
 
//Load the matches for the file
LoadFileMatchesLogic loadFileMatchesLogic = new LoadFileMatchesLogic();
LoadFileResult loadFileResult = loadFileMatchesLogic.LoadFileMatches(searchParms, filePath);
 
foreach (var matchLocation in loadFileResult.MatchLocations)
{
    Console.WriteLine($"{matchLocation.MatchText}: Start {matchLocation.StartPosition}, Length {matchLocation.Length}");
}
'Set the file to load
Dim filePath As String = "C:\_git\Compare-Net-Objects\Compare-NET-Objects-Tests\TestClasses\Invoice.cs"
 
'What to search in the file
Dim searchParms As New SearchParms()
searchParms.SearchString = "FirstName"
searchParms.SearchExpressionType = SearchExpressionType.PlainText
 
'Load the matches for the file
Dim loadFileMatchesLogic As New LoadFileMatchesLogic()
Dim loadFileResult As LoadFileResult = loadFileMatchesLogic.LoadFileMatches(searchParms, filePath)
 
For Each matchLocation In loadFileResult.MatchLocations
    Console.WriteLine($"{matchLocation.MatchText}: Start {matchLocation.StartPosition}, Length {matchLocation.Length}")
Next matchLocation
Requirements

Target Platforms: Windows 7, Windows Vista SP1 or later, Windows XP SP3, Windows Server 2008 (Server Core not supported), Windows Server 2008 R2 (Server Core supported with SP1 or later), Windows Server 2003 SP2

See Also

Reference

LoadFileMatchesLogic Class
LoadFileMatchesLogic Members