Using Jon Skeet's code
static IEnumerable<XElement> 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;
}
}
}
}
}
}
He posted on this thread: Jon Skeet's solution
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
Does the yield within the using not close the reader ? do i have to close it explicitly?
File Move code
File.Move(Path.Combine(InPath, "test.xml"), Path.Combine(OutPath, "test.xml"));
EDIT: It looks like the yield within the using streamreader does not close the file. Can anyone confirm this?