开发者

How to create XDocument from XML file embedded resource

开发者 https://www.devze.com 2023-01-30 02:58 出处:网络
My class library has a folder called \'Foo\' containing an XML file called \'Bar.xml\' whose Build Action is set to Embedded Resource.

My class library has a folder called 'Foo' containing an XML file called 'Bar.xml' whose Build Action is set to Embedded Resource.

I would like to create an XDocument from this file.

How hard can it be?

(Answer: hard开发者_Go百科 enough to stump me for the last half an hour.)


What have you tried so far?! This is normally the way i do it

var manager = new ResourceManager("name.to.my.resource.set", Assembly.GetExecutingAssembly());

using (var s = manager.GetStream("myDoc"))
{
   return XElement.Load(s);
}
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号