473,770 Members | 6,322 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 2228
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
3816
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
4523
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
6522
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
13666
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
3547
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
2548
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
1553
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
9591
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
9425
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 synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10053
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
9867
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...
0
6676
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
5312
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
5449
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
3969
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
3573
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.