您的位置:首页 > 其它

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;       }
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: