comparison api/Factories/Xml/WarFoundryXmlFactory.cs @ 199:70ba3bee0c2e

Fixes #207: WarFoundry still keeps file handles on failure * Move close of zip file into a "finally" block * Remove unnecessary extra Close()
author IBBoard <dev@ibboard.co.uk>
date Mon, 02 Nov 2009 20:58:01 +0000
parents 1d13820b3d96
children c931684f9024
comparison
equal deleted inserted replaced
198:c4cf4c7db7d5 199:70ba3bee0c2e
74 } 74 }
75 75
76 private XmlElement GetRootElementFromStream(Stream stream, WarFoundryXmlElementName elementName) 76 private XmlElement GetRootElementFromStream(Stream stream, WarFoundryXmlElementName elementName)
77 { 77 {
78 XmlDocument doc = WarFoundryXmlFactoryUtils.CreateXmlDocumentFromStream(stream); 78 XmlDocument doc = WarFoundryXmlFactoryUtils.CreateXmlDocumentFromStream(stream);
79 stream.Close(); 79
80 XmlElement elem = (XmlElement)doc.LastChild; 80 XmlElement elem = (XmlElement)doc.LastChild;
81 81
82 if (!elem.LocalName.Equals(elementName.Value)) 82 if (!elem.LocalName.Equals(elementName.Value))
83 { 83 {
84 throw new InvalidFileException(String.Format("Root element of XML was not valid. Expected {0} but got {1}", elementName.Value, elem.Name)); 84 throw new InvalidFileException(String.Format("Root element of XML was not valid. Expected {0} but got {1}", elementName.Value, elem.Name));