Up vote 0 down vote favorite share g+ share fb share tw.
Here's an outline of my solution: I've set the build to Embedded Resource and when I generate the application the XML file doesn't appear in the /Release folder. This is correct, I want this behavior. Now I'm trying to load that file into an XDocument so I can parse the data within: class Program { static void Main(string args) { Console.
WriteLine("Parsing XML. "); XDocument championXml = XDocument. Load("Champions.
Xml"); Console.ReadKey(); } } And I get a file not found error because it's trying to find the xml file in the full path of the release folder. How can I properly load this data into my XDocument? C# .net xml xdocument link|improve this question asked Dec 6 '11 at 20:58Sergio Tapia2,947322 83% accept rate.
1 You need to load the resource, not the file in your project. – jrummell Dec 6 '11 at 21:00 @jrummell: My project doesn't have any resource file. Can you elaborate?
– Sergio Tapia Dec 6 '11 at 21:01.
Use GetManifestResourceStream(): var asm = Assembly. GetExecutingAssembly(); using(var stream = asm. GetManifestResourceStream("Namespace.Champions.
Xml")) { // ... } The exact names used to reference resources can be found by calling GetManifestResourceNames().
I'm using . NET 3.5, and it seems the XDocument. Load(stream) is only available for .
NET 4 and up. I can't use it in my application. How do I use this stream and turn it into xml?
Msdn.microsoft.com/en-us/library/cc838349%28v=vs.95%29.aspx – Sergio Tapia Dec 6 '11 at 21:09 Found my answer in another question. Thanks! Will mark this as answer.
Stackoverflow.com/questions/3281714/… – Sergio Tapia Dec 6 '11 at 21:13.
You should get stream from assembly: Assembly. GetExecutingAssembly(). GetManifestResourceStream(name) Where name will be something like: 'LinqToXml.Champions.xml.
Reference the resource property directly and use Parse instead of load: XDocument championXml = XDocument. Parse(Properties.Resources. ChampionsXML); ^^^^^^^^^^^^ //Name of your resource | The namespace will be somewhat different depending on your project structure.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.