streamreader to read xml file and then file.move to move the xml file - c#
<p>Using Jon Skeet's code</p>

<pre><code>static IEnumerable&lt;XElement&gt; SimpleStreamAxis(string inputUrl,
                                              string elementName)
{
  using (XmlReader reader = XmlReader.Create(inputUrl))
  {
    reader.MoveToContent();
    while (reader.Read())
    {
      if (reader.NodeType == XmlNodeType.Element)
      {
        if (reader.Name == elementName)
        {
          XElement el = XNode.ReadFrom(reader) as XElement;
          if (el != null)
          {
            yield return el;
          }
        }
      }
    }
  }
}
</code></pre>

<p>He posted on this thread:
<a href="http://stackoverflow.com/questions/2441673/reading-xml-with-xmlreader-in-c">Jon Skeet's solution</a></p>

<p>After I read the data, I use File.Move(currentDest,newDest) and I keep getting that the file is currently in use by another process. I have checked to see that there is no editor that has the file open or even browser. In addition I get part of the path could not be found</p>

<p>Does the yield within the using not close the reader ? do i have to close it explicitly?</p>

<p>File Move code</p>

<pre><code>File.Move(Path.Combine(InPath, "test.xml"), Path.Combine(OutPath, "test.xml"));
</code></pre>

<p>EDIT:
It looks like the yield within the using streamreader does not close the file. Can anyone confirm this?</p>
