写web.config文件

+展开
-C#
public static void writeConfig(string item, string key, string value)
    {
        if (item == "")
        {
            item = "appSettings";
        }
        Configuration config = System.Web.Configuration.WebConfigurationManager.OpenWebConfiguration(System.Web.HttpContext.Current.Request.ApplicationPath);
        AppSettingsSection appSection = (AppSettingsSection)config.GetSection(item);
        if (appSection.Settings[key] == null)
        {
            appSection.Settings.Add(key, value);
            config.Save();
        }
        else
        {
            appSection.Settings.Remove(key);
            appSection.Settings.Add(key, value);
            config.Save();
        }
    }

加支付宝好友偷能量挖...


评论(0)网络
阅读(116)喜欢(0)Asp.Net/C#/WCF