Reading xml file from a resource

强颜欢笑 提交于 2019-12-22 05:23:11

问题


I am trying to load an xml file that is stored as a resource in my C# project so I can perform various LINQ queries. However at runtime an "Illegal characters in path" exception is thrown. This is how I am loading the file:

XDocument doc = XDocument.Load(MyProject.Properties.Resources.XMLFile);

回答1:


Wouldn't XMLFile here actually return the xml itself? If so:

XDocument doc = XDocument.Parse(MyProject.Properties.Resources.XMLFile);


来源:https://stackoverflow.com/questions/337535/reading-xml-file-from-a-resource

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!