void LoadFromFileName(string filename)
        {
            FileName = filename;

            StreamReader reader = null;

            try
            {
                if (PreserveWhitespace)
                {
                    PreservationProvider = new XmlAttributePreservationProvider(filename);
                }

                reader = new StreamReader(filename, true);
                LoadFromTextReader(reader);
            }
            finally
            {
                if (PreservationProvider != null)
                {
                    PreservationProvider.Close();
                    PreservationProvider = null;
                }
                reader?.Close();
            }
        }
        private void LoadFromFileName(string filename)
        {
            FileName = filename;

            StreamReader reader = null;

            try
            {
                if (PreserveWhitespace)
                {
                    PreservationProvider = new XmlAttributePreservationProvider(filename);
                }

                using (var stream = File.OpenText(filename))
                {
                    LoadFromTextReader(reader, reader.CurrentEncoding);
                }
            }
            finally
            {
                if (PreservationProvider != null)
                {
                    PreservationProvider.Close();
                    PreservationProvider = null;
                }
                reader?.Dispose();
            }
        }