如何使用c#访问Web配置中的文件夹路径

Raj*_*Raj 2 asp.net c#-4.0

如何使用c#代码从web.config访问文件夹路径.这是一个示例代码.

如何在Web配置中放置此路径 C:\\whatever\\Data\\sample.xml

我必须从web配置中读取此路径.

string folderpath = ConfigurationSettings.AppSettings["path"].ToString();

using (XmlWriter xw = XmlWriter.Create(folderpath, new XmlWriterSettings { Indent = false }))
Run Code Online (Sandbox Code Playgroud)

请帮忙.....

nun*_*cal 9

以下是一些可以帮助您的示例代码

这进入你的web.config.

<configuration>
    <appSettings>
        <add key="myFilePath" value="C:\\whatever\\Data\\sample.xml"/>
    </appSettings>
</configuration>
Run Code Online (Sandbox Code Playgroud)

这就是你读它的方式:

path = System.Web.Configuration.WebConfigurationManager.AppSettings["myFilePath"].ToString();
Run Code Online (Sandbox Code Playgroud)