Hi,
I was going through some test via a C# console mode in order to load somme xml files.
I have XMLFile1.xml with build as resources and XMLFile2.xml with as content and always copy.
string chemin1 = "XMLFile1.xml";
Uri uri1 = new Uri(chemin1, UriKind.RelativeOrAbsolute);
StreamResourceInfo info1 = Application.GetResourceStream(uri1);
and
string chemin2 = "XMLFile2.xml";
Uri uri2 = new Uri(chemin2, UriKind.RelativeOrAbsolute);
StreamResourceInfo info2 = Application.GetContentStream(uri2);
the program.cs file is at the same level as both xml files and
the first solution is ok, info1 is not null but i can't get to make the second work out, info2 is always null.
I Have tried many string such as
chemin2 = "/Debug/XMLFile2.xml";
chemin2 = "/testC#/ConsoleApplication1/ConsoleApplication1/bin/Debug/XMLFile2.xml";
chemin2 = "file:///D:/testC#/ConsoleApplication1/ConsoleApplication1/bin/Debug/XMLFile2.xml";
chemin2 = "pack://siteoforigin:,,,/XMLFile2.xml";
chemin2 = "pack://application:,,,/XMLFile2.xml";
chemin2 = "pack://application:,,,/bin/Debug/XMLFile2.xml";
chemin2 = "/ConsoleApplication1;/XMLFile2.xml";
but i can't get it to work out, thanks in advance for any help anyone could provide sorry for my french.
------------------
1: a very dumb question, what you call the root of the project is where the .csproj is?
2: i tried with your solution and i get an exception with non valid Port
3: i'd really to make the getcontent version workd and understand it
4: i find it strange that i have to use
chemin2 = "../../XMLFile2.xml";
doc = XElement.Load(chemin2)
going backward and not only XMLFile2.xml, is there a way to change that ?