Answer the question
In order to leave comments, you need to log in
How to specify the path to a file in WPF embedded resources?
I specify in XmlReader.Create the path to the xml file that I put in the resources.
Tried some implementation methods, but ran into an error when running "URI prefix not recognized" or "Argument 1: Cannot convert from 'System.Uri' to 'string'".
XmlReader xml = XmlReader.Create(@"pack://application:,,,/Resources/data_on_calculation_types.xml");
XmlReader xml = XmlReader.Create(new Uri(@"pack://application:,,,/Resources/data_on_calculation_types.xml", UriKind.RelativeOrAbsolute));
Answer the question
In order to leave comments, you need to log in
Good afternoon.
In your example you used a non-WPF resource
, it can be accessed as a property (in my case a resource named Data_XMLFile is used):
string res=Properties.Resources.Data_XMLFile;
XmlReader xml2 = XmlReader.Create(new StringReader(res));
Uri uri = new Uri("pack://application:,,,/Resources/Data_XMLFile.xml", UriKind.Absolute);
StreamResourceInfo info = Application.GetResourceStream(uri);
XmlReader xml = XmlReader.Create(info.Stream);
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question