Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using System.Globalization;
- using System.Resources;
- ...
- ResourceSet resourceSet = MyResourceClass.ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true);
- foreach (DictionaryEntry entry in resourceSet)
- {
- string resourceKey = entry.Key.ToString();
- object resource = entry.Value;
- }
- var assembly = Assembly.GetExecutingAssembly();
- foreach (var resourceName in assembly.GetManifestResourceNames())
- System.Console.WriteLine(resourceName);
- foreach (var resourceName in assembly.GetManifestResourceNames())
- {
- using(var stream = assembly.GetManifestResourceStream(resourceName))
- {
- // Do something with stream
- }
- }
- ResXResourceReader rsxr = new ResXResourceReader("your resource file path");
- // Iterate through the resources and display the contents to the console.
- foreach (DictionaryEntry d in rsxr)
- {
- Console.WriteLine(d.Key.ToString() + ":t" + d.Value.ToString());
- }
- // Create a ResXResourceReader for the file items.resx.
- ResXResourceReader rsxr = new ResXResourceReader("items.resx");
- // Create an IDictionaryEnumerator to iterate through the resources.
- IDictionaryEnumerator id = rsxr.GetEnumerator();
- // Iterate through the resources and display the contents to the console.
- foreach (DictionaryEntry d in rsxr)
- {
- Console.WriteLine(d.Key.ToString() + ":t" + d.Value.ToString());
- }
- //Close the reader.
- rsxr.Close();
- Type resourceType = Type.GetType("AssemblyName.Resource1");
- PropertyInfo[] resourceProps = resourceType.GetProperties(
- BindingFlags.NonPublic |
- BindingFlags.Static |
- BindingFlags.GetProperty);
- foreach (PropertyInfo info in resourceProps)
- {
- string name = info.Name;
- object value = info.GetValue(null, null); // object can be an image, a string whatever
- // do something with name and value
- }
- XDocument
- .Load(resxFileName)
- .Descendants()
- .Where(_ => _.Name == "data")
- .Select(_ => $"{ _.Attributes().First(a => a.Name == "name").Value} - {_.Value}");
- ResourceSet resourceSet =
- Resources.ResourceManager.GetResourceSet(CultureInfo.CurrentUICulture, true, true);
- foreach (var entry in resourceSet.OfType<DictionaryEntry>().Select((item, i) => new { Index = i, Key = item.Key, Value = item.Value }))
- {
- Console.WriteLine(@"[{0}] {1}", entry.Index, entry.Key);
- }
Add Comment
Please, Sign In to add comment