473,399 Members | 2,478 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,399 software developers and data experts.

XML and resource

Hi all
I included some xml files to my project as resource...How can I load them at
run time??
thx
Nov 17 '05 #1
5 1389
Hi, this can be done with the ResourceManager Class. There are tons of
examples available in Internet and
also some very good in the MSDN Library...
Best Regards

Kerem Gümrükcü
"Perspolis" <re*****@hotmail.com> schrieb im Newsbeitrag
news:OE**************@TK2MSFTNGP09.phx.gbl...
Hi all
I included some xml files to my project as resource...How can I load them
at
run time??
thx

Nov 17 '05 #2
Hello,
I included some xml files to my project as resource...How can I load
them at
run time??


In Project-Explorer click on the xml file and set (under properties)
Buildaction="Embedded ressource".
So the file will be embedded in the assembly.
The call at runtime is i.e. :
Assembly thisExe = Assembly.GetExecutingAssembly(*);
Stream file=
thisExe.GetManifestResourceStr*eam("myAssemblyName .myXmlFile.xml");
textBoxXML.AppendText(new StreamReader(file).ReadToEnd()*);
file.Close();

In some cases the StreamReader.Read should be with Encoding.Default.
ciao Frank
--
Dipl.Inf. Frank Dzaebel [MCP C#]
http://Dzaebel.NET

Nov 17 '05 #3
thx Frank
good description..
if I want to load it from a dll resource ,Do I have to act this way??
"Frank Dzaebel" <Po**@FranksSeite.de> wrote in message
news:ev*************@TK2MSFTNGP09.phx.gbl...
Hello,
I included some xml files to my project as resource...How can I load them
at
run time??


In Project-Explorer click on the xml file and set (under properties)
Buildaction="Embedded ressource".
So the file will be embedded in the assembly.
The call at runtime is i.e. :
Assembly thisExe = Assembly.GetExecutingAssembly(*);
Stream file=
thisExe.GetManifestResourceStr*eam("myAssemblyName .myXmlFile.xml");
textBoxXML.AppendText(new StreamReader(file).ReadToEnd()*);
file.Close();

In some cases the StreamReader.Read should be with Encoding.Default.
ciao Frank
--
Dipl.Inf. Frank Dzaebel [MCP C#]
http://Dzaebel.NET

Nov 17 '05 #4
Hello perspolis,
if I want to load it from a dll resource, do I have to act this way??


I think, you mean a managed DLL.
Yes you can i.e. with Assembly.LoadFrom() etc.
http://www.codeproject.com/csharp/ReflectionXml.asp

With ASP.NET you have to keep in mind some assembly
locking effects which you can solve with SetShadowCopyPath.
http://www.redtailcanyon.com/items/254265.aspx
ciao Frank
--
Dipl.Inf. Frank Dzaebel [MCP C#]
http://Dzaebel.NET
Nov 17 '05 #5
Hello perspolis,
if I want to load it from a dll resource, do I have to act this way??


I think, you mean a managed DLL.
Yes you can i.e. with Assembly.LoadFrom() etc.
http://www.codeproject.com/csharp/ReflectionXml.asp

With ASP.NET you have to keep in mind some assembly
locking effects which you can solve with SetShadowCopyPath.
http://www.redtailcanyon.com/items/254265.aspx
ciao Frank
--
Dipl.Inf. Frank Dzaebel [MCP C#]
http://Dzaebel.NET
Nov 17 '05 #6

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

Similar topics

11
by: Danny Pressley | last post by:
I have a VS.NET 2003 Visual C++ MFC Application Project in which I added a new resource file, I then added an icon to this new resource file and did a rebuild and got the following error: "fatal...
5
by: John Perks and Sarah Mount | last post by:
When handling resources in Python, where the scope of the resource is known, there seem to be two schools of thought: (1) Explicit: f = open(fname) try: # ... finally: f.close()
5
by: Drew | last post by:
Assembly asm = Assembly.GetExecutingAssembly(); me = new Bitmap(asm.GetManifestResourceStream("me.gif")); I have used this before without any problem, but now I get: An unhandled exception...
0
by: Johann Blake | last post by:
I'm having trouble grasping how ASP.NET correctly locates resources. There is plenty of documentation on this subject but some things are not clear at all. In my ASP.NET application, I have...
7
by: craig | last post by:
....quick question for anyone who might have some experience with .net resource files in VS 2003. I have an application that is not localized, but I would still like to be able to place all of...
13
by: Bob Jones | last post by:
Here is my situation: I have an aspx file stored in a resource file. All of the C# code is written inline via <script runat="server"tags. Let's call this page B. I also have page A that contains...
2
by: WT | last post by:
Hello, Could we use 'Embedded resources' with resx files that contain text resources used in aspx pages with the syntaxe: Text="<%$ Resources:ResourcesMy,KEY1 %>" I tryed removing the...
21
by: DiAvOl | last post by:
Hello, I am using a simple php server that I wrote and have some questions related to the resource id's. When a new client connects to the server or the server opens a file the Resource id...
12
by: TS | last post by:
i have a need to possibly enable mutli language support. What benefit do i get by using a resource file instead of a custom xml solution? thanks!
0
by: CSharper | last post by:
Just curious, When you are in IDE, you are able to add a resource to the project through resource tab. Later this resource can be accessed using the resource manager. One good thing about this...
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
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
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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...

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.