Please tell me why these 2 don't give me the same XmlDocument object.
I can successfully load an external xml file using this code and successfully process the xml file:
var xElem = XElement.Load("Products.xml");Now I embed the xml file as embedded resources in the assembly instead:
var assembly = Assembly.GetExecutingAssembly(); var stream = assembly.GetManifestResourceStream(this.GetType(), "AppNameSpace.Products.xml"); var xElem= new XmlDocument(); xElem.Load(stream);
Aren't the 2 xElem's supposed to be the same? Both XmlDocument containing the same info in Products.xml?
What did I do wrong? Thanks.
If I want to get the same xElem as in scenario 1, what must I do in scenario 2?
GetExecutingAssemblygets the dll of the executing code - if the xml file is in a different assembly, it will not be found.