diff options
author | sr55 <[email protected]> | 2012-04-12 19:51:34 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2012-04-12 19:51:34 +0000 |
commit | 25975e097d8af0e9eb4f3b0f4f38fe7531006c29 (patch) | |
tree | 5bce3ebfec31756c86c10ae2e9c7effda66f8ced | |
parent | 019b2df0b299a3080692cd4b18f146efe5ca41c0 (diff) |
WinGui: (0.9.x) File Handler was not being released, now fixed.
git-svn-id: svn://svn.handbrake.fr/HandBrake/branches/0.9.x@4596 b64f7644-9d1e-0410-96f1-a4d463321fa5
-rw-r--r-- | win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs | 42 |
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 cd535a6bb..8def2c275 100644 --- a/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs +++ b/win/CS/HandBrake.ApplicationServices/Utilities/PlistUtility.cs @@ -386,11 +386,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);
@@ -432,27 +433,28 @@ namespace HandBrake.ApplicationServices.Utilities public static void Export(string path, Preset preset)
{
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>
|