【发布时间】:2015-11-10 06:55:20
【问题描述】:
如何在运行时将更改应用到 resource.resx 文件我的代码如下, 我的问题是资源文件是 resorce.resx 正在改变,但只有在第二次重新加载后才得到它
string xmlPath = Server.MapPath("~/XMLFile1.xml");
string resourcePath = Server.MapPath("~/LocalResource/Resource.sv-SE.resx");
System.Xml.XmlTextReader reader = new XmlTextReader(xmlPath);
ResXResourceWriter writer = new ResXResourceWriter(resourcePath);
while (reader.Read())
{
if (reader.NodeType == XmlNodeType.Element && reader.Name == "string")
writer.AddResource(reader.GetAttribute("name"), reader.ReadString());
}
writer.Generate();
writer.Close();
//here I set it to Thread.CurrentThread.CurrentUICulture = new CultureInfo("sv-SE");
CultureHelper.CurrentCulture = id;
//
// Cache the new current culture into the user HTTP session.
//
Session["CurrentCulture"] = id;
//
// Redirect to the same page from where the request was made!
//
return Redirect(Request.UrlReferrer.ToString());
}
【问题讨论】:
标签: c# asp.net-mvc-4 model-view-controller localization globalization