Configuration files are XML files that can be changed as needed and allow for flexible configuration of applications, either desktop or web. WSS web applications are physically stored in folders under the
C:\Inetpub\wwwroot\wss\VirtualDirectories directory. Each web application has its own folder. The configuration (web.config) file for a web application is located in the root folder for the web application. You can add custom settings to this web configuration file, which InfoPath browser-enabled form templates can access and use.
�
Configuration settings can be programmatically accessed from an InfoPath form template just like from any other .NET application by using classes and methods defined in the
System.Configuration namespace. First you must reference the
System.Configuration assembly in your InfoPath project in Visual Studio or Visual Studio Tools for Applications (VSTA) and then you can write code to retrieve the values of custom configuration settings from the configuration file as shown in the following code:
�
Visual BasicDim�appName As String = System.Configuration.ConfigurationManager.AppSettings("AppName").ToString()
C#string�appName = System.Configuration.ConfigurationManager.AppSettings["AppName"].ToString();
�
where the
appSettings section in the configuration file�has an
add element�that defines�a custom�application setting named
AppName�with a value of
InfoPath2007 as�follows:
�
<appSettings>
� <add key="AppName" value="InfoPath2007" />
</appSettings>
�
Once you have retrieved the value of�the custom application setting from�the configuration file, you can use it in your�InfoPath form template to dynamically configure default values of list boxes, show or hide sections based on conditional formatting, pre-fill fields with data, etc.