File Search Library
CreateIndexIfItDoesNotExist Method
Example 



KellermanSoftware.FileSearchLibrary Namespace > IndexLogic Class : CreateIndexIfItDoesNotExist Method
Search Parameters
Create an index based on search parameters if it does not exist or load the index
Syntax
'Declaration
 
Public Function CreateIndexIfItDoesNotExist( _
   ByVal searchParms As SearchParms _
) As Index
'Usage
 
Dim instance As IndexLogic
Dim searchParms As SearchParms
Dim value As Index
 
value = instance.CreateIndexIfItDoesNotExist(searchParms)
public Index CreateIndexIfItDoesNotExist( 
   SearchParms searchParms
)
public:
Index^ CreateIndexIfItDoesNotExist( 
   SearchParms^ searchParms
) 

Parameters

searchParms
Search Parameters
Remarks
When creating the index it is possible to index all known text files by simply not specifying the FilesToInclude or specify the FilesToInclude as *.* See the ValidExtensions property on the SearchParms for all the file types that can be indexed.
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), "FileSearchLibraryCreateIndexExample");
 
//Create the index if it does not exist
IndexLogic indexLogic = new IndexLogic();
indexLogic.CreateIndexIfItDoesNotExist(searchParms);
'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), "FileSearchLibraryCreateIndexExample")
 
'Create the index if it does not exist
Dim indexLogic As New IndexLogic()
indexLogic.CreateIndexIfItDoesNotExist(searchParms)
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