473,851 Members | 2,270 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 2234
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.n et> wrote in message
news:vv******** ****@corp.super news.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******** ******@TK2MSFTN GP10.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.n et> wrote in message
news:vv******** ****@corp.super news.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.n et> wrote in message
news:vv******** ****@corp.super news.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.GetMan ifestResourceSt ream 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
3825
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 this possible ?
10
4527
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 space. And I could reduce my file size 75% if it was zipped! I have looked at the SharpZipLib web site,...
2
7613
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 resource using Assembly.GetExecutingAssembly() and assembly.GetManifestResourceStream(...) but I...
4
6530
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 to prevent the users from having access to this file. Is there some way to easily embed the text...
0
992
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
13676
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
3552
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
2555
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
1556
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 culture specific resources with the content of the source resource assembly. I aquired upto...
0
11011
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
10670
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
10352
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 choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
7900
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 instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
7072
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
5735
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...
1
4547
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
2
4142
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
3178
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.