Question about ReadXMLSchema...

  • Thread starter Thread starter JG
  • Start date Start date
J

JG

Hi,

I have a quick question regarding the proper use of ReadXmlSchema. For
example I have the following code.

DataSet ds = new DataSet();
ds.ReadXmlSchema("c:\\XMLInputFile.xsd");

I was doing some searches on the web and found this version:

DataSet ds = new DataSet();
FileStream fsSchema = new FileStream("c:\\XMLInputFile.xsd", FileMode.Open,
FileAccess.Read, FileShare.ReadWrite);
ds.ReadXmlSchema(fsSchema);
fsSchema.Close();

My question is this: is there an advantage in using the filestream as
opposed to just using the filename as in my original example? I am just
trying to figure this out...

Any info would be highly appreciated...

thanks,
joe
 
The methods are essentially doing the same thing, however with the second
example you are increasing your control over the filestream and what you do
with it. For example what happens if the filepath does not exist. An
exception would be thrown at the filestream wheras with your example a
FileNotFound exception would be thrown from the DataSet.

Both are valid methods though so I wouldn't get too hung up about either
way.

Br,

Mark.
 
Back
Top