Leggere n file xml mappato su web.config

FAQ di programmazione in .NET

Leggere n file xml mappato su web.config

Messaggioda alesslud » mar giu 13, 2006 8:59 am

<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<appSettings>
<add key="Path" value=".\public\dati.xml"/>
</appSettings>
<connectionStrings/>
<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true"/>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<authentication mode="Windows"/>
<!--
The <customErrors> section enables configuration
of what to do if/when an unhandled error occurs
during the execution of a request. Specifically,
it enables developers to configure html error pages
to be displayed in place of a error stack trace.

<customErrors mode="RemoteOnly" defaultRedirect="GenericErrorPage.htm">
<error statusCode="403" redirect="NoAccess.htm" />
<error statusCode="404" redirect="FileNotFound.htm" />
</customErrors>
-->
</system.web>
</configuration>
alesslud
Site Admin
 
Messaggi: 779
Iscritto il: mer nov 08, 2006 8:09 am

Classe per la lettura

Messaggioda alesslud » mar giu 13, 2006 9:01 am

public XmlDataDocument createDataSource()
{
DataSet dstRecipes = new DataSet();
XmlDataDocument objDataDocument = null;
//dstRecipes.ReadXml(Server.MapPath("./public/dati.xml"));
dstRecipes.ReadXml(ConfigurationManager.AppSettings["Path"]);
objDataDocument = new XmlDataDocument(dstRecipes);
return objDataDocument;
}
alesslud
Site Admin
 
Messaggi: 779
Iscritto il: mer nov 08, 2006 8:09 am

Messaggioda alesslud » ven giu 16, 2006 8:56 am

ConfigurationManager.AppSettings["Path"] è il riferimento alla seguente riga presente su web.config:

<add key="Path" value=".\public\dati.xml"/>
alesslud
Site Admin
 
Messaggi: 779
Iscritto il: mer nov 08, 2006 8:09 am


Torna a .NET

Chi c’è in linea

Visitano il forum: Nessuno e 1 ospite

cron