Get Resource Names from Assembly
<Window x:Class="BinaryResources.Window1"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="BinaryResources" Height="300" Width="300">
<Grid>
<Image Source="c:\image.jpg" />
</Grid>
</Window>
//File:Window.xaml.cs
using System;
using System.Collections.Generic;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Shapes;
using System.IO;
using System.Reflection;
using System.Diagnostics;
using System.Threading;
using System.Resources;
using System.Collections;
using System.Windows.Resources;
namespace BinaryResources
{
public partial class Window1 : System.Windows.Window
{
public Window1()
{
InitializeComponent();
foreach (string streamName in GetResourceNames(typeof(Window1).Assembly, Thread.CurrentThread.CurrentUICulture))
{
Debug.WriteLine(streamName);
}
}
static List<string> GetResourceNames(Assembly asm,System.Globalization.CultureInfo culture)
{
string resourceName = asm.GetName().Name + ".g";
ResourceManager rm = new ResourceManager(resourceName, asm);
ResourceSet resourceSet = rm.GetResourceSet(culture, true, true);
List<string> resources = new List<string>();
foreach (DictionaryEntry resource in resourceSet)
{
resources.Add((string) resource.Key);
}
rm.ReleaseAllResources();
return resources;
}
}
}
Related examples in the same category