diff options
| author | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-08-04 23:41:56 -0400 |
|---|---|---|
| committer | Luke Pulverenti <luke.pulverenti@gmail.com> | 2014-08-04 23:41:56 -0400 |
| commit | c5319bb4ae9606e07d62525a022e5a67f85a7d43 (patch) | |
| tree | 248e5e889e93aa7e2ba2feccf07ca857fe8e6a64 /MediaBrowser.Common/Configuration/ConfigurationHelper.cs | |
| parent | 2714127d2b663b735048da6d9def08efa38f2b5f (diff) | |
update playlist xml saving
Diffstat (limited to 'MediaBrowser.Common/Configuration/ConfigurationHelper.cs')
| -rw-r--r-- | MediaBrowser.Common/Configuration/ConfigurationHelper.cs | 28 |
1 files changed, 16 insertions, 12 deletions
diff --git a/MediaBrowser.Common/Configuration/ConfigurationHelper.cs b/MediaBrowser.Common/Configuration/ConfigurationHelper.cs index 64c2e87de..8c904b0db 100644 --- a/MediaBrowser.Common/Configuration/ConfigurationHelper.cs +++ b/MediaBrowser.Common/Configuration/ConfigurationHelper.cs @@ -36,21 +36,25 @@ namespace MediaBrowser.Common.Configuration configuration = Activator.CreateInstance(type); } - // Take the object we just got and serialize it back to bytes - var newBytes = xmlSerializer.SerializeToBytes(configuration); - - // If the file didn't exist before, or if something has changed, re-save - if (buffer == null || !buffer.SequenceEqual(newBytes)) + using (var stream = new MemoryStream()) { - Directory.CreateDirectory(Path.GetDirectoryName(path)); - - // Save it after load in case we got new items - File.WriteAllBytes(path, newBytes); - } + xmlSerializer.SerializeToStream(configuration, stream); - return configuration; - } + // Take the object we just got and serialize it back to bytes + var newBytes = stream.ToArray(); + + // If the file didn't exist before, or if something has changed, re-save + if (buffer == null || !buffer.SequenceEqual(newBytes)) + { + Directory.CreateDirectory(Path.GetDirectoryName(path)); + // Save it after load in case we got new items + File.WriteAllBytes(path, newBytes); + } + + return configuration; + } + } /// <summary> /// Reads an xml configuration file from the file system |
