For example, I have a configuration file that corresponds to the address of the Substation Site and the data in the database and needs to be read when the program starts. As follows:
Ericsth@Gmail.Com
-
<?xml version="1.0" encoding="utf-8"?>
-
<!--
-
Configure DoMain and merchant ID prefix
-
-->
-
<DoMain>
-
<SubMain name="qz" pre="01002"></SubMain>
-
<SubMain name="yw" pre="01003"></SubMain>
-
<SubMain name="wl" pre="01030"></SubMain>
-
<SubMain name="cq" pre="02001"></SubMain>
-
<SubMain name="cq" pre="02002"></SubMain>
-
</DoMain>
Click the properties of the file and set it to an embedded resource.
- Introduce this Assembly (dll) in Global. asax. cs:
Ericsth@Gmail.Com
-
protected void Application_Start(object sender, EventArgs e)
-
{
-
// log4net.Config.XmlConfigurator.Configure(new System.IO.FileInfo("Log4Net.config"));
-
// When the system is started, first configure the ing between the substation and the city Prov code
-
Assembly assembly = Assembly. Load ("Assembly name ");
-
Stream stream = assembly. GetManifestResourceStream ("assembly name. DoMainMapping. cfg. xml ");
-
XmlDocument xmlDoc = null;
-
xmlDoc = new XmlDocument();
-
xmlDoc.Load(stream);
-
}
At this point, you can get the information of this configuration file!