diff options
Diffstat (limited to 'win/CS/HandBrake.ApplicationServices/Utilities')
-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 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>
|