title: c# xml.Load() locking file on disk causing errors
body: <p>I have a simple class XmlFileHelper as follows:</p>
  
  <pre><code>public class XmlFileHelper
  {
      #region Private Members
  
      private XmlDocument xmlDoc = new XmlDocument();
      private string xmlFilePath;
  
      #endregion
  
      #region Constructor
  
      public XmlFileHelper(string xmlFilePath)
      {
          this.xmlFilePath = xmlFilePath;
          xmlDoc.Load(xmlFilePath);
      }
  
      #endregion
  
      #region Public Methods
  
      public XmlNode SelectSingleNode(string xPathQuery)
      {
          return xmlDoc.SelectSingleNode(xPathQuery);
      }
  
      public string GetAttributeValueByName(XmlNode node, string attributeName)
      {
          return node.Attributes.GetNamedItem(attributeName).Value;
      }
  
      #endregion
  
      #region Public Properties
  
      public string XmlFilePath
      {
          get
          {
              return xmlFilePath;
          }
      }
  
      #endregion
  }
  </code></pre>
  
  <p>The issue is I am getting the following error on Load:</p>
  
  <pre><code>System.IO.IOException: The process cannot access the file ''C:\CvarUAT\ReportWriterSettings.xml'' **because it is being used by another process**
  </code></pre>
  
  <p>this occurs when this class is used to by two running instances of a component running in parallel both attempting to load the xml file above, this is legitimate behaviour and required by the application.</p>
  
  <p>I only want to read in the xml off disk once and release any reference to the file on disk and use an in memory representation from that point forward.</p>
  
  <p>I would have assumed Load operates in a readonly fashion and would have no need to lock the file, what is my best way to achieve the desired result and get around this issue?</p>
  
  <p>Thanks</p>