summaryrefslogtreecommitdiffstats
path: root/win/CS/HandBrake.ApplicationServices/Utilities
diff options
context:
space:
mode:
authorsr55 <[email protected]>2012-04-12 19:51:19 +0000
committersr55 <[email protected]>2012-04-12 19:51:19 +0000
commit8dfb6d1874dbdac2754882b62e1e023af0c515a5 (patch)
treedd7a630b13ae1c206d1b2fb1fca70d426444c61d /win/CS/HandBrake.ApplicationServices/Utilities
parentf3c2acc2e605655b26091b202f74981ae0486bea (diff)
WinGui: File Handler was not being released, now fixed.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@4595 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Utilities')
-rw-r--r--win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs42
1 files changed, 22 insertions, 20 deletions
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();
+ }
}
/// <summary>