title: Disposing an XDocument object
body: <p>How do I "dispose" an XDocument object? I am using it to parse an XML string and then save the file to the file system. In the same method I then need to access this file and run a command line tool on it.</p>
  
  <p>The code is as follows:</p>
  
  <pre><code>string filepath = "...";
  string filename = "...";
  XDocument xdoc = XDocument.Parse(xmlString);
  xdoc.Save(filepath + filename);
  
  Process p = Process.Start(new ProcessStartInfo("rst.exe", args)); // the args use the file saved above
  </code></pre>
  
  <p>I put a breakpoint on the line where I call the command line tool, and then tried to open the file manually myself, but it wouldn't load until I stopped the debugger.</p>
  
  <p><strong>edit:</strong> Thanks for the answers. I've narrowed down the problem.. after the file is saved, and with the breakpoint on "Process p = ...", I <em>am</em> able to open the file, but I can't access it using <code>http://qualifiedapppath/path/file.xml</code>, and the command line tool I am using will only accept a URL as a parameter. After stopping the debugger, I am able to access the file through http. What process is preventing access to it while the method is running?</p>