Today, when refactoring code, you want to embed the following XML file in the assembly and read at run time:
<?xml version= "1.0" encoding= "Utf-8"?> <convertors xmlns=
"http://tempuri.org/~vs24E.xsd" >
<Convertor>
<Name>1</Name>
<Category>1</Category>
<description >1</Description>
</Convertor>
<Convertor>
<Name>2</Name>
< category>2</category>
<Description>2</Description>
</Convertor>
< convertor>
<Name>3</Name>
<Category>3</Category>
<Description> 3</description>
</Convertor>
</Convertors>
Looked everywhere, all about reading. txt and. resx-type embedded resources, and then a flash, try the following methods:
private static Convertordata Getconvertordata ()
{
Assembly Assembly = typeof (Convertorprovider). Assembly;
System.IO.Stream Stream = assembly. GetManifestResourceStream ("TextConvertor.Convertor.xml");
Convertordata data = new Convertordata ();
Data. READXML (stream);
return data;
}
It is probably the first to get the Assembly object, and then get the stream object, then it is good to do, or read the XmlDocument, or read the data set based on the XML file.