-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSoundStorageXML.cs
35 lines (33 loc) · 927 Bytes
/
SoundStorageXML.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
using System.Collections.Generic;
using System.IO;
using System.Xml.Serialization;
namespace BasicTwitchSoundPlayer.SoundStorage
{
class SoundStorageXML
{
public static List<SoundEntry> LoadSoundBase(string XmlPath)
{
List<SoundEntry> entries;
if (!File.Exists(XmlPath))
{
entries = new List<SoundEntry>();
SaveSoundBase(XmlPath, entries);
}
else
{
XmlSerializer xmlSerializer = new XmlSerializer(typeof(List<SoundEntry>));
FileStream fs = new FileStream(XmlPath, FileMode.Open);
entries = (List<SoundEntry>)xmlSerializer.Deserialize(fs);
fs.Dispose();
}
return entries;
}
public static void SaveSoundBase(string XmlPath, List<SoundEntry> entries)
{
XmlSerializer xmlSerializer = new XmlSerializer(typeof(List<SoundEntry>));
FileStream fs = new FileStream(XmlPath, FileMode.OpenOrCreate);
xmlSerializer.Serialize(fs, entries);
fs.Dispose();
}
}
}