is there a way to inspect if a resource file is in the exe or not?

C

CSharper

During compilation, I am including a resource file and I want to check
the exe to see if the resource file I added available?
Is there any other way to see what are all the resources available in
an assembly, without really knowing the names?
Thanks.
 
M

Marc Gravell

If you mean as a quick check, then Lutz to the rescue (again) via
Reflector, which shows resources for assemblies (or Resourcer for
working on resx pre-build): http://www.aisto.com/roeder/dotnet/

If you mean routinely through code - then you can find the resources
with things like:
http://groups.google.com/group/micr...1529d341b73/6927617afef9a9ee#29bededfba28f246

But if the resource is a resx, you need to parse the resx stream -
something like below (crude and incomplete).

Marc

Assembly assembly = typeof(Program).Assembly;
foreach (string name in
assembly.GetManifestResourceNames())
{
try
{
using (ResourceReader reader = new
ResourceReader(assembly.GetManifestResourceStream(name)))
{
foreach (DictionaryEntry pair in reader)
{
Console.WriteLine("{0}: {1}", pair.Key,
pair.Value);
}
}
}
catch
{ // not a resx...?

}
}
 
C

CSharper

If you mean as a quick check, then Lutz to the rescue (again) via
Reflector, which shows resources for assemblies (or Resourcer for
working on resx pre-build):http://www.aisto.com/roeder/dotnet/

If you mean routinely through code - then you can find the resources
with things like:http://groups.google.com/group/microsoft.public.dotnet.languages.csha...

But if the resource is a resx, you need to parse the resx stream -
something like below (crude and incomplete).

Marc

Assembly assembly = typeof(Program).Assembly;
foreach (string name in
assembly.GetManifestResourceNames())
{
try
{
using (ResourceReader reader = new
ResourceReader(assembly.GetManifestResourceStream(name)))
{
foreach (DictionaryEntry pair in reader)
{
Console.WriteLine("{0}: {1}", pair.Key,
pair.Value);
}
}
}
catch
{ // not a resx...?

}
}

excellent. Thanks.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top