读取XML

    public sealed class ConfigManger
    {
        public XDocument XmlDocs { set; get; }

        string path = @"{0}ConfigurationServer{1}";
        public ConfigManger()
        {
            LoadFiles();
        }

        public static ConfigManger Instance
        {
            get
            {
                return ConfigCreateXML.Singleton;
            }
        }

        public class ConfigCreateXML
        {

            static ConfigCreateXML() { }

            internal static readonly ConfigManger Singleton = new ConfigManger();
        }

        void LoadFiles()
        {
            string filePath = string.Format(path, AppDomain.CurrentDomain.BaseDirectory, "ServerPath.config");
            if (XmlDocs == null)
            {
                XmlDocs = XDocument.Load(filePath);
            }
        }
    }
原文地址:https://www.cnblogs.com/LiMin/p/3403857.html