ixGAMEOVERxixx Posted October 4, 2009 Report Posted October 4, 2009 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.
iBotPeaches Posted October 5, 2009 Report Posted October 5, 2009 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); } }
ixGAMEOVERxixx Posted October 5, 2009 Author Report Posted October 5, 2009 Never mind got it to work, thanks anyway peaches.
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now