![]() |
|
[.NET] Embedded Resource Byte Array - Printable Version +- Hack Forums (https://hackforums.net) +-- Forum: Tech (https://hackforums.net/forumdisplay.php?fid=444) +--- Forum: Coding (https://hackforums.net/forumdisplay.php?fid=151) +---- Forum: Software Development (https://hackforums.net/forumdisplay.php?fid=118) +---- Thread: [.NET] Embedded Resource Byte Array (/showthread.php?tid=4379964) |
Embedded Resource Byte Array - cwood - Aug 5, 2014 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? * - Furious` - Aug 5, 2014 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 * - Zettabit - Aug 6, 2014 The ResourceManager class can accomplish what you need. http://msdn.microsoft.com/en-us/library/system.resources.resourcemanager(v=vs.110).aspx * - cwood - Aug 6, 2014 (Aug 6, 2014 02:31 AM)Zettabit Wrote: The ResourceManager class can accomplish what you need. 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. * - cwood - Aug 7, 2014 (Aug 5, 2014 07:50 PM)Furious` Wrote: The My class is generated by the Visual Studio IDE but not when using CodeDomThis solution worked. I used a memory stream to convert to a byte array. |