且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

从资源读取XML文件

更新时间:2023-11-13 18:32:46

岂不 XMLFILE 这里居然返回XML本身呢?如果是这样的:

 的XDocument DOC = XDocument.Parse(MyProject.Properties.Resources.XMLFile); 


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);

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

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