sharepoint 读取/_layouts/15/目录webconfig配置方法
2017-07-25 17:24
309 查看
本文顺便记录下,如何读取sharepoint的15目录下,webconfig配置文件属性值的方法。 // <summary> ///读取/_layouts/15/目录下,webconfig配置方法 ///</summary> public static stringGetConnectionString(stringConnectionName) { string path = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); string CurrentPath = path + @"\CommonFiles\Microsoft Shared\web serverextensions\15\TEMPLATE\LAYOUTS\web.config"; XmlDocument doc = new XmlDocument(); doc.Load(CurrentPath); XmlNode node = doc.SelectSingleNode("/configuration/connectionStrings/add[@name=\"" + ConnectionName + "\"]"); XmlElement element = (XmlElement)node; string _connectionString = element.GetAttribute("connectionString"); return _connectionString; } // <summary> ///读取/_layouts/15/目录下,webconfig配置方法 ///</summary> public static string GetAppSettings(string AppSettingsKey) { string path = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles); string CurrentPath = path + @"\CommonFiles\Microsoft Shared\web serverextensions\15\TEMPLATE\LAYOUTS\web.config"; XmlDocument doc = new XmlDocument(); doc.Load(CurrentPath); XmlNode node = doc.SelectSingleNode("/configuration/appSettings/add[@key=\"" + AppSettingsKey + "\"]"); XmlElement element = (XmlElement)node; string _connectionString = element.GetAttribute("value"); return _connectionString; }
相关文章推荐
- 配置子目录Web.config使其消除继承,用虚拟目录创建多个网站的方法
- 配置子目录Web.config使其消除继承,用虚拟目录创建多个网站的方法
- 关于ASP.NET C#配置Web.config的方法及读取方法
- 配置子目录Web.config使其消除继承,用虚拟目录创建多个网站的方法
- 【转】配置子目录Web.config使其消除继承,用虚拟目录创建多个网站的方法
- 禁止虚拟目录继承根目录下web.config中的有些配置 web.config的继承禁止方法
- 禁止虚拟目录继承根目录下web.config中的有些配置 web.config的继承禁止方法
- [转]WinForm和WebForm下读取app.config web.config 中邮件配置的方法
- 配置子目录Web.config使其消除继承,用虚拟目录创建多个网站的方法
- WEB 项目中读取 WEB-INF 目录下配置文件的方法
- asp.net2.0中读取web.config连接字符串或是其他配置信息的方法
- web和winform中读取config配置文件的方法
- Web.config文件中节点的配置数值读取的2种方法,哪种更快?
- ASP.NET-ASP.NET配置(web.config)无法连接到SQL Server 数据库的解决方法
- 前台直接读取Web.config中的值的方法
- Web.config中配置数据库的方法
- 读取Web.config内的配置数据
- 安装AJAX Documents 时候发生的web.config文件配置错误的解决方法
- 指定文件名读取WEB-INFO目录下properties配置(windows平台)
- Web.config中appSettings的两种读取方法