How to read a resource file within a Portable Class Library?

后端 未结 8 1716
夕颜
夕颜 2020-12-05 03:26

I have a Portable Library which I am using for a Windows Phone application. In that same Portable Library, I have a couple of content files (Build Action = Cont

8条回答
  •  借酒劲吻你
    2020-12-05 03:49

    var assembly = typeof(PegHelper).GetTypeInfo().Assembly;
    using (var stream = assembly.GetManifestResourceStream("Parsers.Peg.SelfDef.xml"))
    using (var reader = new StreamReader(stream))
    {
        string xmlText = reader.ReadToEnd();
        return XDocument.Parse(xmlText);
    }
    

提交回复
热议问题