Reputation: 45
I have found this code from Youtube, which shows how to extract embedded resources, with my modification that will extract from another application.
private static void Extract(string FileName, string nameSpace, string outDirectory, string internalFilePath, string resourceName)
{
Assembly assembly = Assembly.LoadFile(FileName);
string ManifestString = nameSpace + '.' + (internalFilePath == "" ? "" : internalFilePath + ".") + resourceName;
using (Stream s = assembly.GetManifestResourceStream(ManifestString))
using (BinaryReader r = new BinaryReader(s))
using (FileStream fs = new FileStream(outDirectory + "\\" + resourceName, FileMode.OpenOrCreate))
using (BinaryWriter w = new BinaryWriter(fs))
w.Write(r.ReadBytes((int)s.Length));
}
Do we have any Delphi equivalent code for this?
Upvotes: 0
Views: 209
Reputation: 613592
I'd say you have two options.
The first option is really no fun at all. The CLR API is very powerful, but also has a steep learning curve.
The second option is quite straightforward. Use C# and export functionality via COM, or perhaps with UnmanagedExports. That would allow you to use the code from the question. Or use a mixed model C++/CLI class library and expose classic unmanaged DLL exports that expose the functionality. This would require you to convert the code from the question into C++.
Upvotes: 2