Using the Assembly.GetFile(string) method?

K

Kyle Kaitan

I have the following code:
Assembly asm = Assembly.LoadFrom("Foo.dll");
foreach (string s in asm.GetManifestResourceNames())
{
Console.WriteLine("found manifest resource: " + s);
}

FileStream fs = asm.GetFile( ??? );
<<<<<

Suppose I have a resource file called "Xyz.resx" embedded in the Foo.dll
assembly above. (Xyz also shows up as one of the items on the WriteLine
output too.) What should replace the '???' to generate the FileStream
properly? I've tried everything I can think of and still no dice.

Any help would be appreciated. Thanks!
 
J

Jon Skeet [C# MVP]

Assembly asm = Assembly.LoadFrom("Foo.dll");
foreach (string s in asm.GetManifestResourceNames())
{
Console.WriteLine("found manifest resource: " + s);
}

FileStream fs = asm.GetFile( ??? );
<<<<<

Suppose I have a resource file called "Xyz.resx" embedded in the Foo.dll
assembly above. (Xyz also shows up as one of the items on the WriteLine
output too.) What should replace the '???' to generate the FileStream
properly? I've tried everything I can think of and still no dice.

Use asm.GetManifestResourceStream - and it won't return a FileStream,
just a Stream.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top