473,386 Members | 1,705 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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

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.
Jun 27 '08 #1
2 981
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/micro...bededfba28f246

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...?

}
}
Jun 27 '08 #2
On Apr 29, 3:02 am, Marc Gravell <marc.grav...@gmail.comwrote:
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/micro...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.
Jun 27 '08 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Thomas Guettler | last post by:
Hi, the line numbers of inspect.getinnerframes are different from traceback.format_exception. This results in wrong lines being shown in cgitb. An example is below. I looked at the...
2
by: Fernando Perez | last post by:
Hi all, IPython has suffered quite a few problems with the inspect module in python 2.3. For these, unfortunately all I've been able to do is guard with overreaching except clauses, as I had...
11
by: It's me | last post by:
I discovered the hardway what inspect.isclass() is doing. Consider this no brainer code: ### import inspect class Abc: def Hello(self): return
4
by: Benjamin Rutt | last post by:
I'm trying to learn about introspection in Python. my ultimate goal is to be able to build a module "text database" of all modules that are in the sys.path, by discovering all candidate modules...
1
by: aj | last post by:
What is the difference (if any) between inspect check database and db2dart ??? Do they both find the same potential problems? Does one provide more comprehensive checking than the other? ...
4
by: Chris Pax | last post by:
Hello, I recently been trying to use the inspect module to inspect the arguments of gtk objects, such as gtk.Button. I tried like this: inspect.getargspec(gtk.Button.__init__) and get the...
0
by: Stef Mientki | last post by:
hello, I'm not familiar with inspect, but I get an error (see below) in getmembers ( wx ) Of course this is bug in wx . But would you also call this a bug in inspect ?
0
by: Stef Mientki | last post by:
Gabriel Genellina wrote: REALLY GREAT ! But this is fully beyond my understanding: m = getmembers ( wx ) print m runs fine print getmembers ( wx )
0
by: rajasankar | last post by:
Hi, I am using Jython based application and trying to use inspect.py in the python files. Here is my code import inspect,os,sys,pprint,imp def handle_stackframe_without_leak(getframe): ...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.