How to add binary data to executable ?

O

Oleg Subachev

I need to add binary data to C# executable and then read it back
during execution or from another application.

In Delphi for Win32 I used the following:
- created binary Win32 resource with needed data;
- linked this resource with executable through {$RESOURCE <filename>}
directive;
- during execution I used TResourceStream to read binary data;
- from another application I used
LoadLibraryEx/EnumResourceNames/FindResource/
LoadResource/LockResource to read the same binary data.

How to implement the same functionality from C# ?

Oleg Subachev
 
J

Jon Skeet [C# MVP]

Oleg said:
I need to add binary data to C# executable and then read it back
during execution or from another application.

In Delphi for Win32 I used the following:
- created binary Win32 resource with needed data;
- linked this resource with executable through {$RESOURCE <filename>}
directive;
- during execution I used TResourceStream to read binary data;
- from another application I used
LoadLibraryEx/EnumResourceNames/FindResource/
LoadResource/LockResource to read the same binary data.

How to implement the same functionality from C# ?

Add it as an embedded resource in your project (assuming you're using
Visual Studio) and then use Assembly.GetManifestResourceStream.

Jon
 
O

Oleg Subachev

Add it as an embedded resource in your project (assuming you're using
Visual Studio) and then use Assembly.GetManifestResourceStream.

Thanks.

Then ResourceReader( GetManifestResourceStream ) allows read
name=value pairs containing in the resource.

Oleg Subachev
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top