From 8dfb6d1874dbdac2754882b62e1e023af0c515a5 Mon Sep 17 00:00:00 2001 From: sr55 Date: Thu, 12 Apr 2012 19:51:19 +0000 Subject: WinGui: File Handler was not being released, now fixed. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4595 b64f7644-9d1e-0410-96f1-a4d463321fa5 --- .../Utilities/PlistUtility.cs | 42 +++++++++++----------- 1 file changed, 22 insertions(+), 20 deletions(-) (limited to 'win/CS/HandBrake.ApplicationServices/Utilities') diff --git a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs index 96e8d917c..bfe717b7e 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs @@ -440,11 +440,12 @@ namespace HandBrake.ApplicationServices.Utilities if (!File.Exists(filename)) return null; - StreamReader sr = File.OpenText(filename); string fromfile = string.Empty; - int fileChar; - while ((fileChar = sr.Read()) != -1) - fromfile += Convert.ToChar(fileChar); + using (StreamReader sr = File.OpenText(filename)) + { + int fileChar; + while ((fileChar = sr.Read()) != -1) fromfile += Convert.ToChar(fileChar); + } XmlDocument doc = new XmlDocument(); doc.LoadXml(fromfile); @@ -491,27 +492,28 @@ namespace HandBrake.ApplicationServices.Utilities } EncodeTask parsed = QueryParserUtility.Parse(preset.Query); - XmlTextWriter xmlWriter = new XmlTextWriter(path, Encoding.UTF8) { Formatting = Formatting.Indented }; - - // Header - xmlWriter.WriteStartDocument(); - xmlWriter.WriteDocType("plist", "-//Apple//DTD PLIST 1.0//EN", - @"http://www.apple.com/DTDs/PropertyList-1.0.dtd", null); + using (XmlTextWriter xmlWriter = new XmlTextWriter(path, Encoding.UTF8) { Formatting = Formatting.Indented }) + { + // Header + xmlWriter.WriteStartDocument(); + xmlWriter.WriteDocType( + "plist", "-//Apple//DTD PLIST 1.0//EN", @"http://www.apple.com/DTDs/PropertyList-1.0.dtd", null); - xmlWriter.WriteStartElement("plist"); - xmlWriter.WriteStartElement("array"); + xmlWriter.WriteStartElement("plist"); + xmlWriter.WriteStartElement("array"); - // Add New Preset Here. Can write multiple presets here if required in future. - WritePreset(xmlWriter, parsed, preset); + // Add New Preset Here. Can write multiple presets here if required in future. + WritePreset(xmlWriter, parsed, preset); - // Footer - xmlWriter.WriteEndElement(); - xmlWriter.WriteEndElement(); + // Footer + xmlWriter.WriteEndElement(); + xmlWriter.WriteEndElement(); - xmlWriter.WriteEndDocument(); + xmlWriter.WriteEndDocument(); - // Closeout - xmlWriter.Close(); + // Closeout + xmlWriter.Close(); + } } /// -- cgit v1.2.3