Reading embedded XML file c#

后端 未结 6 992
春和景丽
春和景丽 2020-11-27 13:07

How can I read from an embedded XML file - an XML file that is part of a c# project? I\'ve added a XML file to my project and I want to read from it. I want the XML file to

6条回答
  •  伪装坚强ぢ
    2020-11-27 13:31

    You can use Reflector (free from http://www.red-gate.com/products/reflector/) to find the path to the embedded XML file.

    Then, it's just a matter of

    Assembly a = typeof(Assembly.Namespace.Class).Assembly;
    
    Stream s = a.GetManifestResourceStream("Assembly.Namespace.Path.To.File.xml");
    XmlDocument mappingFile = new XmlDocument();
    mappingFile.Load(s);
    s.Close();
    

提交回复
热议问题