Home Upgrade Search Memberlist Extras Hacker Tools Award Goals Help Wiki Contact

.NET 

Embedded Resource Byte Array

I am trying to get the byte array of an embedded resource. The file is compiled with CodeDom and "My.Resources.file" does not work like it does with a normal project. It gives me this error: 'Resources' is not a member of 'My'. I also tried two other ways to get the byte array but couldn't get the ResourceManager to work. How do I do this?
The My class is generated by the Visual Studio IDE but not when using CodeDom
You could generate the class yourself, try to view the code using ILSpy or you could use reflection:
Imports System.Reflection

Assembly me = Assembly.GetExecutingAssembly()
Stream resourceStream = me.GetManifestResourceStream("file")

You could then use a binary reader or a memory stream to convert the stream to a byte array
The ResourceManager class can accomplish what you need.

http://msdn.microsoft.com/en-us/library/....110).aspx
шкідливе ПО для ентузіастів

Jabber: [email protected]
[email protected]

(Aug 6, 2014 02:31 AM)Zettabit Wrote:  The ResourceManager class can accomplish what you need.

http://msdn.microsoft.com/en-us/library/....110).aspx

I tried this. How do I find the name of the resource file? System.Reflection.Assembly.GetExecutingAssembly.GetManifestResourceNames shows the embedded resources but did not display the resource file.
(Aug 5, 2014 07:50 PM)Furious` Wrote:  The My class is generated by the Visual Studio IDE but not when using CodeDom
You could generate the class yourself, try to view the code using ILSpy or you could use reflection:
Imports System.Reflection

Assembly me = Assembly.GetExecutingAssembly()
Stream resourceStream = me.GetManifestResourceStream("file")

You could then use a binary reader or a memory stream to convert the stream to a byte array
This solution worked. I used a memory stream to convert to a byte array.


Possibly Related Threads...
Thread / Author Replies Views Last Post
[C#] by Julius013Mar 2, 2022 05:12 PM 4 311 Mar 2, 2022 05:12 PM
Last Post: Julius013
[C#] by VoidlightFeb 19, 2021 10:54 AM 9 711 Feb 19, 2021 10:54 AM
Last Post: arsium
[C] by gurlhackerclubMay 19, 2020 05:18 PM 8 259 May 19, 2020 05:18 PM
Last Post: k1r3n