Creating the Configuration File
A configuration file is simply an XML file with the appropriate tags and an appropriate name. A configuration file for an application will have the name <name>.<extension>.config, where <name> is the name of the application, and <extension> is the extension of the application (such as .exe). Thus, the .config file for an application named myApplication.exe would be myApplication.exe.config. A configuration file must be located in the same folder as the application assembly that it configures.The content of a configuration file must be configured in the .config file schema. The basic structure of a configuration file is as follows:
<?xml version="1.0"
encoding="utf-8" ?>
<configuration>
<appSettings>
<configuration>
<appSettings>
<add key="DBConnectionString" value="Data
Source=GTC;Initial Catalog=IntangibleDemo;User
Id=sa;Password=Tech8092"></add>
</appSettings>
</configuration>
Aside from the first element,
which specifies the XML version and the encoding, and the top-level
<configuration> element, there is no required content for a configuration
file. All other elements are optional and can be added or dispensed with as
needed. In C# Program
using System.Configuration;
string SQL_CON = System.Configuration.ConfigurationManager.
AppSettings.Get("DBConnectionString");
string SQL_CON =
ConfigurationSettings.AppSettings["DBConnectionString"].ToString();
Process
Class
//To open the
Calculator
System.Diagnostics.Process.Start("calc");
//To open any
file
System.Diagnostics.Process.Start("PathOfFileWithExtension");
No comments:
Post a Comment