File Search Library
SearchIndex Method
Example 



KellermanSoftware.FileSearchLibrary Namespace > IndexLogic Class : SearchIndex Method
Search Parameters
Search an index by the passed search parameters
Syntax
'Declaration
 
Public Function SearchIndex( _
   ByVal searchParms As SearchParms, _
   ByVal index As Index _
) As List(Of String)
'Usage
 
Dim instance As IndexLogic
Dim searchParms As SearchParms
Dim index As Index
Dim value As List(Of String)
 
value = instance.SearchIndex(searchParms, index)

Parameters

searchParms
Search Parameters
index

Return Value

A list of matched files
Example
//Setup the search parameters
SearchParms searchParms = new SearchParms();
 
//This is the directory to index
searchParms.DirectoriesToSearch.Add(@"c:\_git");
 
//Include all C# files by wildcard
searchParms.FilesToInclude.Add("*.cs");
searchParms.FileIncludeSearchType = FileSearchType.Wildcard;
 
//Set the directory to save the index
searchParms.IndexPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "FileSearchLibrarySearchIndexExample");
 
//Create the index
IndexLogic indexLogic = new IndexLogic();
Index index = indexLogic.CreateIndexIfItDoesNotExist(searchParms);
 
//Specify what to search
searchParms.SearchString = "public partial class";
searchParms.SearchExpressionType = SearchExpressionType.PlainText;
 
//List the files that are found
List<string> files = indexLogic.SearchIndex(searchParms, index);
 
foreach (string file in files)
{
    Console.WriteLine(file);
}
'Setup the search parameters
Dim searchParms As New SearchParms()
 
'This is the directory to index
searchParms.DirectoriesToSearch.Add("c:\_git")
 
'Include all C# files by wildcard
searchParms.FilesToInclude.Add("*.cs")
searchParms.FileIncludeSearchType = FileSearchType.Wildcard
 
'Set the directory to save the index
searchParms.IndexPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData), "FileSearchLibrarySearchIndexExample")
 
'Create the index
Dim indexLogic As New IndexLogic()
Dim index as new Index = indexLogic.CreateIndexIfItDoesNotExist(searchParms)
 
'Specify what to search
searchParms.SearchString = "public partial class"
searchParms.SearchExpressionType = SearchExpressionType.PlainText
 
'List the files that are found
Dim files As List(Of String) = indexLogic.SearchIndex(searchParms, index)
 
For Each file As String In files
    Console.WriteLine(file)
Next file
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

IndexLogic Class
IndexLogic Members