473,763 Members | 6,149 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Resource file question!

I am using VS2008 C#3.0 and I would like to know if some one can help
me wiith the following 2 questions;
1. I have a XML file called test.xml file in resource and I would like
to how can I read the xml file wihtout extracting it to a external
file? I would like to load the object into memory and use it from
there.
2. I am planning to have too many data files in the resource file, is
it possible to compress the resource file and then use it?

Thanks.
Mar 21 '08 #1
2 1350
On Fri, 21 Mar 2008 13:53:57 -0700, Peter Duniho
<Np*********@nn owslpianmk.comw rote:
I don't recall the specifics off the top of my head, but it should be
possible to get a MemoryStream from a binary resource. So if you just
treat the XML file resource as a binary resource, you should be able to
wrap that in a MemoryStream and then just read it normally as a regular
stream.
FYI...I took a quick look and sure enough the binary resource shows up as
a regular byte[]. So you can just use the MemoryStream constructor that
takes a byte[] array as the source.
Mar 21 '08 #2
On Fri, 21 Mar 2008 17:54:53 -0700, Jeroen Mostert <jm******@xs4al l.nl>
wrote:
I wasn't looking for a fight along the "my idea is better than yours"
divide.
Nor am I. It's just that inexperienced programmers too often get caught
up in the "let's make this optimal" approach that it's worth pointing out
at opportune moments that just because something is more performant, that
doesn't mean it's the best approach.

I don't have a problem with your contribution, but that doesn't mean I
think it should be left without some additional commentary pointing out
that in at least what should be a typical case (ie relatively small
resources), it's likely to be better to choose a simpler option.

I'm sure it wasn't your intent, but describing the alternatives you
suggested as having "saving the overhead..." carries an implication that
it's a better solution in an objective, unqualified way. In fact, of
course, it's only "better" in certain context, context I think was worth
pointing out.
Or a discussion on things that I hope everyone can decide for their own.
When all of the facts, they can.
>But you're right...if someone really wants to get a stream directly,
they can.
Let's promote this to my main point and forget about my ill-advised
dropping of the "o" word, lest I be branded as an optimization bum and
an enemy of simplicity for the rest of my life, which would be a shame.
Yes, indeed. :)

Pete
Mar 22 '08 #3

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

Similar topics

1
5860
by: Gabriel Lozano-Morán | last post by:
First of all sorry for the cross-posting but I am not sure wether this belongs under internationalization or just general. Environment: Visual Studio .NET 2003 Problem: Newly added and renamed resource files are not automatically linked to the object they belong by the IDE
5
1822
by: Julia | last post by:
Hi, I need to localize my asp.net application and I would like to populate drop down box from a resource file I see that ms localization tool kit can save lists in a resource file but I don't want to use it How would you save a collection in a resource file?
8
1820
by: Bonj | last post by:
when creating a resource-only dll, the only way I can get it to compile and work correctly, is to make it a non-resource-only dll. surely this can't be the way...? basically, there is a load of resources, in a dll. The DLL is a managed class library, but it has got an unmanaged function that accesses the resources. FindResource only works on the HMODULE that is gained by casting the HINSTANCE passed to DllMain into an HMODULE (I think...
2
1687
by: Joe Thompson | last post by:
Hi, I am trying to use PlaySound in a VC++.net Windows app (VS 2003). I can use it to play a file but now I want to play it from a resource. I have two questions: How do I add a wav file to my project as a resource (steps please) How do I call PlaySound once that I have the wav file as part of the resource.
1
2540
by: mehdi_mousavi | last post by:
Hi folks, Consider a string that's defined under VS2005 resource editor as myField with the value of myValue. To access the value, I could easily use the Properties.Resources class, for example: global::myNameSpace.Properties.Resources.myField However, I would like to retreive it's string representation of the field's name, i.e., the "myField". How am I supposed to do that?
1
2845
by: John | last post by:
Can some one please help me with this code? I've spend 2 days on it. And I see the question all over the place but I do not see the answer. No on is answering the question I am about to ask. I am trying to (inside my c++ exe file) include a resource (my swf) file and open it the Create Window command I found at the following url. http://www.codeproject.com/useritems/FlashGui.asp
8
13665
by: CodeLeon | last post by:
Hi, All. I am creating a setup program. The way it works is that the user creates their setup info, my program generates the C# code for a setup executable, embeds the xml file containing the info for the setup, and compiles the whole thing into one EXE. How do i embed resources, and access them, into that assembly?
7
2107
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 the images that are used for icons across all of the forms in all of the assemblies in a single resource file so that swaping out an image in the resource file affects all localtions that it appears in the app. Is there a way to create a single...
12
5276
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
1990
by: =?Utf-8?B?UGF1bCBIYWdlcg==?= | last post by:
I've been trying to solve this issue for the better part of a month. My attempts to get an answer on the MSDN groups proved to no avail. Here is the situation/problem. I am migrating an old piece of software developed using VC++ 4.2, running on Windows NT 3.51 to VC++ 2005, running on Windows XP Pro SP2. I went through all of the necessary gyrations to reach the point where all of the deprecated functions were dealt with. I got a...
0
9563
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10144
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
9997
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8821
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
6642
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5270
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
5405
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3917
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
3
3522
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.