QSMP.Utility/Files/Configs.cs
(开头部分) 2KB这里只显示每个文件的开头 60 行。登录后可以解锁完整代码。
using System;
using System.Configuration;
using System.Web;
using System.Xml;
namespace QSMP.Utility.Files
{
public class Configs
{
/// <summary>
/// 配置文件相对路径。
/// </summary>
private const string CONGIG_PATH = "/Configs/AppSetting.config";
/// <summary>
/// 根据Key取Value值。
/// </summary>
/// <param name="key">键</param>
public static string GetValue(string key)
{
return ConfigurationManager.AppSettings[key].ToString().Trim();
}
public static int GetValueInt(string key)
{
try
{
return Convert.ToInt32(GetValue(key));
}
catch
{
return 0;
}
}
public static bool GetBoolValue(string key)
{
if (GetValue(key).ToLower() == "True".ToLower())
{
return true;
}
return false;
}
/// <summary>
/// 根据Key修改Value。
/// </summary>
/// <param name="key">键</param>
/// <param name="value">值</param>
public static void SetValue(string key, string value)
{
XmlDocument doc = new XmlDocument();
doc.Load(HttpContext.Current.Server.MapPath(CONGIG_PATH));
XmlNode xNode;
xNode = doc.SelectSingleNode("//appSettings");
XmlElement modifyElem = (XmlElement)xNode.SelectSingleNode("//add[@key='" + key + "']");
if (modifyElem != null)
{
modifyElem.SetAttribute("value", value);
}
else
后面还有 10 行代码,解锁后查看完整代码
24 小时内免费解锁 3 个项目,之后 1 积分/个。 规则说明
AI 解读
登录后可用,每次 10 积分,解读结果公开显示在下面。
还没有人解读过这个文件。
