Click here to Skip to main content
15,742,323 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi, I am creating resource file at runtime in WPF its creating and displaying in resource filder but not showing in solution though refresh the folder also. When i do it manually add exsiting item, then only its adding please help me out how to add it to solution when ever its creating.

Thanks in advance...

My code is:

C#
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[i]["ResourceName"].ToString(), dsResources.Tables[0].Rows[i]["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;
        }
    }
Posted

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900