Ana içeriğe atla


Kasım, 2021 tarihine ait yayınlar gösteriliyor

How to read .Net Resource Files all content

Once in a day, when I need to read all resx file contents and put all of them into database I tried to find resource with googling but I couldn't find any proper solution to read efficiently so I tried to create a method in a basic way of xml reading.  To read all key and values from .net resource language map files. Following method can be used :   private static Dictionary<string, string> GetResourceFile(string languageCode)         {             Dictionary<string, string> langMap = new Dictionary<string, string>();             string fileName = $"SharedResource.{languageCode}.resx";             string fullPath = "D:\\projects\\projectName\\Resources\\" + fileName;             XDocument xDoc = XDocument.Load(fullPath);             foreach (XElement item in xDoc.Root.Elements("data"))             {                 string key = item.Attribute("name").Value;                 string value = item.Element("value").Value