My friend and I are learning to program by creating and solving little challenges for each other. In the most recent one, he hid something in the resources of his program. I can find and save the resource off manually using .NET Reflector; but I am trying to do this in a programmatic fashion with C# and not having much luck.

It seems access to resources can be gained via the Assembly object (maybe?) but I haven't been able to use this approach for accessing external files, only the currently executing program.

What objects and methods do I need to extract resources from an external file?

M. W. Jones

If the resource file is in the executing folder, you can set the basename to the name of the resource file (without the extension) and use the EntryAssemly intead of the Executing one.

Hothe this helps.

Thanks! Here is my code that solved my problem:

// hisFile is type string, e.g. @"C:\path\program.exe"
// hisResourceName is type string and is the name of the resource

Assembly myAssembly = Assembly.LoadFile(hisFile);
ResourceManager resourceManager = new ResourceManager("app.resources", myAssembly);
byte[] myData = GetResource(hisResourceName, myAssembly);

Now all of the data that was in the resource is in the myData byte array.

This question has already been answered. Start a new discussion instead.