本文整理汇总了C#中SiteSettings.WriteToXml方法的典型用法代码示例。如果您正苦于以下问题:C# SiteSettings.WriteToXml方法的具体用法?C# SiteSettings.WriteToXml怎么用?C# SiteSettings.WriteToXml使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类SiteSettings
的用法示例。
在下文中一共展示了SiteSettings.WriteToXml方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: SaveMasterSettings
static void SaveMasterSettings(SiteSettings settings)
{
string masterSettingsFilename = GetMasterSettingsFilename();
XmlDocument doc = new XmlDocument();
if (File.Exists(masterSettingsFilename))
{
doc.Load(masterSettingsFilename);
}
settings.WriteToXml(doc);
doc.Save(masterSettingsFilename);
}
示例2: SaveSiteSettings
/// <summary>
/// 保存站点配置
/// </summary>
/// <param name="errorMsg"></param>
/// <returns></returns>
bool SaveSiteSettings(out string errorMsg)
{
bool flag = false;
errorMsg = null;
if ((siteName.Length > 30) || (siteDescription.Length > 30))
{
errorMsg = "网店名称和简单介绍的长度不能超过30个字符";
}
try
{
//获取本站点配置路径
string filename = Request.MapPath(Globals.ApplicationPath + "/config/SiteSettings.config");
XmlDocument doc = new XmlDocument();
SiteSettings settings = new SiteSettings(Request.Url.Host, null);
doc.LoadXml("<?xml version=\"1.0\" encoding=\"utf-8\"?>" + Environment.NewLine + "<Settings></Settings>");
settings.SiteName = siteName;
settings.SiteDescription = siteDescription;
settings.WriteToXml(doc);
//保存站点配置信息
doc.Save(filename);
flag = true;
}
catch (Exception exception)
{
errorMsg = exception.Message;
}
return flag;
}