我在运行时创建资源文件WPF
。
它正在资源文件夹中创建并显示,但即使在刷新文件夹后,它也没有显示在解决方案中。
当我手动执行(add exsiting item
)时,它正在被添加。
如何在创建解决方案时将其添加到解决方案中?
我的代码是:
public void LaguageCulture(string languageid)
{
try
{
SqlParameter[] param = new SqlParameter[1];
param[0] = new SqlParameter("@lagid", languageid);
//languageid =3
var dsResources = SqlHelper.ExecuteDataset(_objSqlConnection, "sproc_GetResourceNames", param);
string culturecode = string.Empty;
if (dsResources.Tables[1].Rows.Count > 0)
{
culturecode = dsResources.Tables[1].Rows[0][0].ToString();
}
FileInfo file = new FileInfo(System.Windows.Forms.Application.StartupPath.Replace("\\bin\\Debug", "") + "\\Resources\\EnglishResource." + culturecode + ".resx"); // Culture code is en-US
if (!file.Exists)
{
var resx = new ResXResourceWriter(System.Windows.Forms.Application.StartupPath.Replace("\\bin\\Debug", "") + "\\Resources\\EnglishResource." + culturecode + ".resx");
if (dsResources.Tables[0].Rows.Count > 0)
{
for (var i = 0; i < dsResources.Tables[0].Rows.Count; i++)
{
resx.AddResource(dsResources.Tables[0].Rows["ResourceName"].ToString(), dsResources.Tables[0].Rows["ResourceValue"].ToString());
}
}
resx.Generate();
//Application.Current.Resources.Add(culturecode + ".resx", resx);
resx.Close();
}
System.Threading.Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture(culturecode);
System.Threading.Thread.CurrentThread.CurrentUICulture = CultureInfo.CreateSpecificCulture(culturecode);
}
catch (Exception)
{
throw;
}
}