Enclose the doc.Load(...) statement in the try-finally block and add the
following in the "finally" clause:
try
{
file.Close();
}
catch(IOException)
{
// Optionally add something like this here:
// Debug.WriteLine("Failed to close the file");
}
"Nick" <ni*********@hotmail.com> wrote in message
news:a0**************************@posting.google.c om...
Hi,
simple question
XmlDocument doc = new XmlDocument();
FileStream file = new FileStream
(PathAndFileName,FileMode.Open,FileAccess.Read,Fil eShare.ReadWrite);
doc.Load(file);
should I now call file.close or do I not need to??
Thanks
Nick