- Create a class called Chapter3 (if you have not done so already) that contains two methods. One method reads the XML file, and the second method logs any exception errors:
public void ReadXMLFile(string fileName) { try { bool blnReadFileFlag = true; if (blnReadFileFlag) { File.ReadAllLines(fileName); } } catch (Exception ex) { Log(ex); throw; } } private void Log(Exception e) { /* Log the error */ }
- In the console application, add the following code to call the ReadXMLFile method, passing it the filename to read:
Chapter3 ch3 = new Chapter3();string File = @"c:tempXmlFile.xml";ch3.ReadXMLFile(File);
- Running the application will generate an error (assuming that you actually don't have a file called XMLFile.xml in your ...