Show language: C# VB.NET Both
Associated with every Index Directory is a configuration.xml file, which holds the settings associated with the index. The configuration.xml file resides inside the Index Directory.
Whenever an index is worked with (import or search) a configuration object must be loaded. If the operation is programmatic then a Configuration object (holding the settings) must be passed to the various components. If the operation is part of the provided tools (Index Manager Tool, Visual Studio designer, Web Admin* or Windows Service*) then the configuration is loaded from the configuration.xml file.
The Configuration class holds the settings for index operations, but is transient (settings are not automatically persisted). To persist the settings to the index, use the ConfigurationManager class.
Eg. to save a configuration instance
//Create a new instance, with default settings
Configuration conf = new Configuration();
//Make some changes
conf.CaseSensitivity = CaseSensitivity.Capitalization;
conf.WebsiteCredentials.Add("keyoti.com", new ResourceCredentials("user", "pass"));
//Write this configuration to an index directory "myIndexDir"
ConfigurationManager cm = new ConfigurationManager( @"c:\inetpub\wwwroot\myIndexDir");
cm.SaveSettings(conf);
'Create a new instance, with default settings
Dim conf As Configuration = New Configuration
'Make some changes
conf.CaseSensitivity = CaseSensitivity.Capitalization
conf.WebsiteCredentials.Add("keyoti.com", New ResourceCredentials("user", "pass"))
'Write this configuration to an index directory "myIndexDir"
Dim cm As ConfigurationManager = New ConfigurationManager("c:\inetpub\wwwroot\myIndexDir")
cm.SaveSettings(conf)
Eg. to load a configuration instance
//Create a new instance, with default settings
Configuration conf = new Configuration();
//Load this configuration instance with settings from index directory "myIndexDir"
ConfigurationManager cm = new ConfigurationManager( @"c:\inetpub\wwwroot\myIndexDir");
cm.RetrieveConfiguration(conf);
'Create a new instance, with default settings
Dim conf As Configuration = New Configuration
'Load this configuration instance with settings from index directory "myIndexDir"
Dim cm As ConfigurationManager = New ConfigurationManager("c:\inetpub\wwwroot\myIndexDir")
cm.RetrieveConfiguration(conf)
The conf object can then be passed in the constructor of any object you create that requires the configuration.
The Configuration object has an IndexDirectory property which can be set to the absolute file path of the Index Directory.
-If the Configuration object is not loaded via ConfigurationManager then the IndexDirectory property will need to be set before it can be used.
-If the Configuration object is loaded via ConfigurationManager, then the IndexDirectory property will be set automatically to the path where the configuration file is (i.e. the index directory).
*Pro level only