473,529 Members | 3,145 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How do Embed a file as a resource?

M
Hi Folks,

Does anyone know how to embed a file into a resource in C#? You
seem to be able to embed Icon, Bitmap, Cursor's & Strings. But how do you
embed a file???

In VC++ version 6 you would, Find the Resource, Load It, get its size, and
then write it out to where ever you want it.

Any help would be most appreciated.

Cheers,

Martin


Nov 15 '05 #1
3 2219
Hi M,

Select file in Solution Explorer, go to Properties and set Build Action to
Embedded Resource.

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rhand.com

"M" <a1*****@ic24.net> wrote in message
news:vv************@corp.supernews.com...
Hi Folks,

Does anyone know how to embed a file into a resource in C#? You seem to be able to embed Icon, Bitmap, Cursor's & Strings. But how do you
embed a file???

In VC++ version 6 you would, Find the Resource, Load It, get its size, and
then write it out to where ever you want it.

Any help would be most appreciated.

Cheers,

Martin

Nov 15 '05 #2
M
Hi Miha Markic,
Select file in Solution Explorer, go to Properties and set Build Action to
Embedded Resource.
AND ????????

How do I Serialize it out?????

The Icon Bitmap & Cursor Classes ALL have special constructors ie
Class(GetType(),"FileName");

If the file was for instance an MS-Access Database file, how do you copy it
to the required location????

Martin

"Miha Markic" <miha at rthand com> wrote in message
news:ex**************@TK2MSFTNGP10.phx.gbl... Hi M,

Select file in Solution Explorer, go to Properties and set Build Action to
Embedded Resource.

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rhand.com

"M" <a1*****@ic24.net> wrote in message
news:vv************@corp.supernews.com...
Hi Folks,

Does anyone know how to embed a file into a resource in C#?

You
seem to be able to embed Icon, Bitmap, Cursor's & Strings. But how do you embed a file???

In VC++ version 6 you would, Find the Resource, Load It, get its size, and then write it out to where ever you want it.

Any help would be most appreciated.

Cheers,

Martin


Nov 15 '05 #3
Hi M,
"M" <a1*****@ic24.net> wrote in message
news:vv************@corp.supernews.com...
Hi Miha Markic,
Select file in Solution Explorer, go to Properties and set Build Action to Embedded Resource.


AND ????????

How do I Serialize it out?????


Check out Assembly.GetManifestResourceStream method.

--
Miha Markic - RightHand .NET consulting & development
miha at rthand com
www.rhand.com
Nov 15 '05 #4

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

Similar topics

2
3801
by: Eric Barr | last post by:
I've found myself using XSD files for my datasets. I'm loading them up from disk right now. I was hoping there was a way to embed the file in the assembly, so I could have access to it without the disk read. I know I could build a kludge of a string builder function ...I was looking for a way to embed the entire file in my assembly. Is...
10
4500
by: Yogi_Bear_79 | last post by:
pardon my ignorance as I am a self-taught hobbyist programmer. I am curious after reading up on SharpZipLib. Can I embed a zipped txt file in my program? Then either read from within the zip file or unzip and read it? I currently have an embedded text file that contains a list that is read into an array. I'm always looking to save...
2
7594
by: David | last post by:
Hello, I'm using an xml schema (xsd file) to validate input xml. This xsd is used by the C# dll and must be distributed with it. The xsd isn't modified. So I would like to embed it in the DLL so that I don't have to worry about the path where the file is stored... How do I embed the xsd file into my DLL? I know how to get the file back from...
4
6506
by: David | last post by:
I have an application that creates a database from a text file of DDL (generated by Visio). Currently I have to deploy the text file with my application and open it using the statement: SQL = My.Computer.FileSystem.ReadAllText("CreateDB.SQL"). This works fine, but I would prefer not to have to deploy a separate text file, and I would like...
0
981
by: John | last post by:
Hi This is my question: I have an Exe and a .resource that i modify with Lutz Resourcer. I can't manage to embed the modified resource file in the exe with al.exe. al.exe myexe.exe /target:exe /out:newexewithnewres.exe /embed:myresource.resource
8
13654
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?
4
3520
by: bern11 | last post by:
How do you embed a custom cursor? The help says: // On the command line: // Add the following flag: // /res:CursorFileName.Cur,Namespace.CursorFileName.Cur What if you are compiling with the IDE? I don't see a 'command line options' field anywhere...???
8
2528
by: Tomasz J | last post by:
Hello Developers, It may sound like a stupid question, but how to embed a resource in ASP.Net 2.0 web application? I mean, without using a separate library. There is no "build action" property. Thanks, Tomasz J
0
1519
by: VigneshS | last post by:
Hi, I am a newbie to Globalization and Localisation Concepts. I tried almost all the methods of the Globalization concepts. But i cannot be able to embed a text file within a Resource. My need is to open a solution programmatically, select a Project within, and get a source resource file. Then, select a number of cultures and create...
0
7356
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...
0
7278
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7519
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. ...
0
7674
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...
0
7629
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
1
5206
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
4836
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...
1
1739
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
1
902
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.