如何使用C#访问Web配置中的文件夹路径 [英] How to access the folder path in web config using c#
本文介绍了如何使用C#访问Web配置中的文件夹路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用c#代码从web.config访问文件夹路径。
是示例代码。
How can i access the folder path from web.config using c# code. here is a sample code.
如何将此路径放置在Web配置中 C:\\无论hat Data\\sample.xml
how to place this path in web config C:\\whatever\\Data\\sample.xml
我必须从Web配置读取此路径。
i have to read this path from web config.
string folderpath = ConfigurationSettings.AppSettings["path"].ToString();
using (XmlWriter xw = XmlWriter.Create(folderpath, new XmlWriterSettings { Indent = false }))
请帮助.....
推荐答案
下面的示例代码将为您提供帮助
Here is some sample code that should help you
这进入您的web.config。
This goes into your web.config.
<configuration>
<appSettings>
<add key="myFilePath" value="C:\\whatever\\Data\\sample.xml"/>
</appSettings>
</configuration>
这就是您的阅读方式:
path = System.Web.Configuration.WebConfigurationManager.AppSettings["myFilePath"].ToString();
这篇关于如何使用C#访问Web配置中的文件夹路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文