Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Find embedded resource names in assembly?

In C# or else VB.Net, there is a way to find the embedded resource(s) contained in an assembly?

Because I'm manually extracting an embedded resource form an assembly in this way:

    Dim embeddedFileName As String = "MyResources.resx"
    Dim targetFilePath As String = "C:\NewMyResources.resx"
    Using s As Stream = assembly.GetManifestResourceStream(embeddedFileName)
        Dim buffer As Byte() = New Byte(CInt(s.Length - 1)) {}
        Dim read As Integer = s.Read(buffer, 0, CInt(s.Length))
        Using fs As New FileStream(targetFilePath, FileMode.Create)
            fs.Write(buffer, 0, buffer.Length)
        End Using
    End Using

I would like to automate the task in future projects to extract the resource(s) without knowing the exact name(s), it is possible?

like image 432
ElektroStudios Avatar asked Feb 22 '26 17:02

ElektroStudios


1 Answers

You can get a list of embedded resources with the Assembly.GetManifestResourceNames method.

like image 129
Blorgbeard Avatar answered Feb 25 '26 07:02

Blorgbeard



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!