Click here to Skip to main content
15,888,216 members
Home / Discussions / C#
   

C#

 
AnswerRe: How to add Binary Resources Pin
turbochimp4-Sep-05 16:34
turbochimp4-Sep-05 16:34 
I would look closely at the System.Resources.ResourceWriter class; I think it does everything you're looking for.

I actually used it one time when I wanted to embed some sound in a Windows app.

Something like the following would probably do the trick if you're just wanting to write binary resources to the file:

using System;
using System.IO;
using System.Resources;
using System.Runtime.Serialization.Formatters.Binary;

class ResourceUtility
{
	public static void WriteResourceToFile(string name, object graph, string fileName)
	{
		// Serialize the resource
		BinaryFormatter serializer = new BinaryFormatter();
		MemoryStream mem = new MemoryStream();
		serializer.Serialize(mem, graph);

		// Write the serialized graph to a resource file.
		using (ResourceWriter writer = new ResourceWriter(fileName))
		{
			writer.AddResource(name, mem.GetBuffer());
			writer.Generate();
			writer.Close();
		}
	}
}


The most exciting phrase to hear in science, the one that heralds the most discoveries, is not 'Eureka!' ('I found it!') but 'That's funny...’

GeneralRe: How to add Binary Resources Pin
Heinz_5-Sep-05 9:51
Heinz_5-Sep-05 9:51 
GeneralRe: How to add Binary Resources Pin
turbochimp6-Sep-05 11:21
turbochimp6-Sep-05 11:21 
GeneralRe: How to add Binary Resources Pin
Heinz_7-Sep-05 19:55
Heinz_7-Sep-05 19:55 
GeneralRe: How to add Binary Resources Pin
turbochimp7-Sep-05 20:43
turbochimp7-Sep-05 20:43 
GeneralRe: How to add Binary Resources Pin
Heinz_8-Sep-05 11:31
Heinz_8-Sep-05 11:31 
Questionplz help me Pin
Sayed Sajjad Raza Zaidi3-Sep-05 20:12
Sayed Sajjad Raza Zaidi3-Sep-05 20:12 
AnswerRe: plz help me Pin
Mohamad Al Husseiny4-Sep-05 10:14
Mohamad Al Husseiny4-Sep-05 10:14 
Questionparse string by using xml Pin
savage_3-Sep-05 13:50
savage_3-Sep-05 13:50 
AnswerRe: parse string by using xml Pin
Guffa3-Sep-05 15:11
Guffa3-Sep-05 15:11 
QuestionPlease Help:Marshaling Question?? Pin
E6AD3-Sep-05 12:51
E6AD3-Sep-05 12:51 
QuestionURGENTLY complicated Pin
malak nour3-Sep-05 12:03
malak nour3-Sep-05 12:03 
AnswerRe: URGENTLY complicated Pin
Judah Gabriel Himango3-Sep-05 12:26
sponsorJudah Gabriel Himango3-Sep-05 12:26 
Questionhelp regarding server monitoring Pin
vkas_in_guj3-Sep-05 10:10
vkas_in_guj3-Sep-05 10:10 
AnswerRe: help regarding server monitoring Pin
Dave Kreskowiak3-Sep-05 11:34
mveDave Kreskowiak3-Sep-05 11:34 
QuestionHow to Convert this in C# Pin
majidbhutta3-Sep-05 8:21
majidbhutta3-Sep-05 8:21 
Answer[Message Deleted] Pin
philip_cole3-Sep-05 9:18
philip_cole3-Sep-05 9:18 
AnswerRe: How to Convert this in C# Pin
philip_cole3-Sep-05 9:30
philip_cole3-Sep-05 9:30 
QuestionReflection Emit Pin
Yoyosch3-Sep-05 7:07
Yoyosch3-Sep-05 7:07 
AnswerRe: Reflection Emit Pin
if_mel_yes_else_no3-Sep-05 8:38
if_mel_yes_else_no3-Sep-05 8:38 
QuestionTime change events Pin
monrobot133-Sep-05 6:25
monrobot133-Sep-05 6:25 
AnswerRe: Time change events Pin
if_mel_yes_else_no3-Sep-05 8:29
if_mel_yes_else_no3-Sep-05 8:29 
QuestionHttpWebRequest Timeout Problem Pin
surfman193-Sep-05 4:30
surfman193-Sep-05 4:30 
AnswerRe: HttpWebRequest Timeout Problem Pin
Andy Brummer3-Sep-05 14:21
sitebuilderAndy Brummer3-Sep-05 14:21 
GeneralRe: HttpWebRequest Timeout Problem Pin
surfman193-Sep-05 14:36
surfman193-Sep-05 14:36 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.