I need some code which allows you to extract a resource from my application. I know you can run a .exe embeded as a resource in an application.. so extracting should be easy as well.
iBotModz CBox
[Request] Extract a resource.
Started by ixGAMEOVERxixx, Oct 04 2009 12:08 PM
2 replies to this topic
#1
Posted 04 October 2009 - 12:08 PM
#2
Posted 05 October 2009 - 05:56 AM
I use a function for that. I think this is it.
/// <summary> /// Extracts an embedded file out of a given assembly. /// </summary> /// <param name="assemblyName">The namespace of you assembly.</param> /// <param name="fileName">The name of the file to extract.</param> /// <returns>A stream containing the file data.</returns> public static Stream GetEmbeddedFile(string assemblyName, string fileName) { try { System.Reflection.Assembly a = System.Reflection.Assembly.Load(assemblyName); Stream str = a.GetManifestResourceStream(assemblyName + "." + fileName); if(str == null) throw new Exception("Could not locate embedded resource '" + fileName + "' in assembly '" + assemblyName + "'"); return str; } catch(Exception e) { throw new Exception(assemblyName + ": " + e.Message); } }
#3
Posted 05 October 2009 - 03:02 PM
Never mind got it to work, thanks anyway peaches.