How to get resources embedded in another project

前端 未结 2 1405
没有蜡笔的小新
没有蜡笔的小新 2020-12-15 18:19

Let us say I have a C# class library project, which only contains xml files as embedded resources. I would like to access these resources from another solution project. As t

2条回答
  •  失恋的感觉
    2020-12-15 18:45

    you can use Assembly.GetManifestResourceStream() to load the xml file from the embedded assembly.

    System.IO.Stream s = this.GetType().Assembly.GetManifestResourceStream("ActivityListItemData.xml"); 
    

    EDIT

    You can use Assembly.Load() and load the target assembly and read the resource from there.

    Assembly.LoadFrom("Embedded Assembly Path").GetManifestResourceStream("ActivityListItemData.xml");
    

提交回复
热议问题