H
heday60
I've got this application that watches a directory for XML's and then
parses them into a DB. It then moves them based on if the XML was
succesful or a bad XML...
foreach(FileInfo file in dir.GetFiles("*.xml"))
{
try
{
ParseXML(file.FullName);
}
catch
{
FilesToMoveError.Add(file.FullName);
break;
}
FilesToMove.Add(file.FullName);
fileCount++;
}
}
moveFiles();
The parsing is as such, and this is my latest iteration to attempt to
make sure hte reader is closed.
public void ParseXML(string filename)
{
XmlReader xmlReader = null;
try
{
FileStream stream = new FileStream(filename,
FileMode.Open,FileAccess.Read);
xmlReader = new XmlTextReader (stream);
while(!xmlReader.EOF)
{
xmlReader.Read();
switch (xmlReader.NodeType)
{
}
}
}
catch (XmlException e)
{
DebugLog(null, "Error parsing XML " + e.Message);
}
finally
{
if (xmlReader != null)
{
xmlReader.Close();
}
}
}
When I hit the file.move in my move files function it gives me the
exception "file used by another process"
What am I missing??
Thanks
parses them into a DB. It then moves them based on if the XML was
succesful or a bad XML...
foreach(FileInfo file in dir.GetFiles("*.xml"))
{
try
{
ParseXML(file.FullName);
}
catch
{
FilesToMoveError.Add(file.FullName);
break;
}
FilesToMove.Add(file.FullName);
fileCount++;
}
}
moveFiles();
The parsing is as such, and this is my latest iteration to attempt to
make sure hte reader is closed.
public void ParseXML(string filename)
{
XmlReader xmlReader = null;
try
{
FileStream stream = new FileStream(filename,
FileMode.Open,FileAccess.Read);
xmlReader = new XmlTextReader (stream);
while(!xmlReader.EOF)
{
xmlReader.Read();
switch (xmlReader.NodeType)
{
}
}
}
catch (XmlException e)
{
DebugLog(null, "Error parsing XML " + e.Message);
}
finally
{
if (xmlReader != null)
{
xmlReader.Close();
}
}
}
When I hit the file.move in my move files function it gives me the
exception "file used by another process"
What am I missing??
Thanks