I have code that calls the ReadXml method of the DataSet class and passes in a file name ReadXml(strFileName). Occasionally this throws a System.IO.IOException because the file is being used by another process.
If I change the code to use the ReadXml(stream) method and pass in a FileStream like this:
using(FileStream fs = new FileStream(this.filename, FileMode.Open, FileAccess.Read, FileShare.ReadWrite ))
{
MyDS.ReadXxml(FileStream);
}
Will that prevent the IOException from occuring? What is going on under the hood when you simply pass in a file name?