473,396 Members | 1,706 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,396 software developers and data experts.

Looking for file path of an embedded resource

What class / method should I be using to get the full path to
an embedded resource ? In my case I have an .xml file
that my app uses, it is set as embedded resource, and
I have a control that needs to load it, but I do not want to hard
code the path since that may change for different installs.
i.e. GetPathForResourceOfName ( myResourceFileName )

thanks,

JIM

Nov 15 '05 #1
1 24093
You can't get the filename of an embedded resource because it's embedded!
i.e. The contents of the file is copied into the assembly (DLL or EXE)
during the build process.

- Lee

"james" <no****@hypercon.net> wrote in message
news:O$**************@TK2MSFTNGP09.phx.gbl...
Lee, yes I need the file name with full path

that's why I was thinking of GetPathForResourceOfName (
myResourceFileName )
this would give me the path for a resopurce of some name in my embedded
resources.
My control already has the code to load the file given the name.

thanks,

JIM

"Lee Chapman" <Please Reply To Group> wrote in message
news:OY**************@TK2MSFTNGP09.phx.gbl...
Do you want the data in the file or the filename? I use the following to
access the contents of an embedded file:

Stream stream =
Assembly.GetExecutingAssembly().GetManifestResourc eStream(name);

Note that the name needs to include the default namespace for the project. e.g. If the default namespace was My.Namespace and the file with its build action set to "Embedded Resource" was called TextFile1.txt then you'd need to pass "My.Namespace.TextFile1.txt" to GetManifestResourceStream().

You can check what the name to use for a built assembly by loading the
assembly into ildasm.exe, opening the manifest, and looking for the

relevant
.mresource entry.

e.g.
.mresource public My.Namespace.TextFile1.txt
{
}
- Lee
"james" <no****@hypercon.net> wrote in message
news:Of*************@TK2MSFTNGP12.phx.gbl...
What class / method should I be using to get the full path to
an embedded resource ? In my case I have an .xml file
that my app uses, it is set as embedded resource, and
I have a control that needs to load it, but I do not want to hard
code the path since that may change for different installs.
i.e. GetPathForResourceOfName ( myResourceFileName )

thanks,

JIM



Nov 15 '05 #2

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

Similar topics

1
by: Leonardo D'Ippolito | last post by:
Hello sirs, I have a project for a .DLL in .NET that has an XML file as embedded resource. Is it possible to update/substitute this embedded resource in the DLL without having to re-compile the...
1
by: Cindy Liu | last post by:
Hi, I have a VS.Net project that has a resource file set as embedded resource. To compile the project via VS, I have no problem. But our build system uses compiler command, not VS.Net. How to...
3
by: Ron Vecchi | last post by:
I have a text file(.js) that holds a buch of java script code that is rendered in some web controls all part of a larger webcontrol library. The file is rather large. Would embedding this...
7
by: Christofer Dutz | last post by:
Hi, I am trying to read a XML-File which I marked as embedded resource from within the code of my DLL. Unfortunately it doesn't work. On my search for the error I inserted some code for...
4
by: Jason Pettys | last post by:
In an ASP.NET project I am setting the content type of my .ascx and ..aspx files to Embedded Resource for a separate reason. When I do this they get embedded as "RootNamespace.Filename" but I...
1
by: photochop | last post by:
I know the question of whether or not a SWF file can be read in by a ..NET application has been asked a billion times, however, what I'm asking is whether or not it is possible (any examples?...
0
by: WRH | last post by:
Hello I have a C# app with a small separate .chm help file. I would like to declare this as an embedded resource. Is there a way to make the helpprovider use this resource without extracting and...
8
by: raylopez99 | last post by:
I have the latest version of Visual Studio 2008 Professional, which allows you to create resource files (this is the .resx file, no?), unlike the Express version, which does not. I am trying to...
1
by: guizawa | last post by:
Hi all, I am experimenting Walter Wang's code to try to load .swf file from embedded resource to webbrowser in window form but get error: "An object reference is required for the non-static...
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: 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
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.