fixed directory issue with preferences.
This commit is contained in:
parent
eeebff355f
commit
831c49b685
@ -1,6 +1,7 @@
|
||||
using RhythmBullet.Zer01HD.Utilities.Persistence;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
@ -12,12 +13,13 @@ namespace RhythmBullet.Zer01HD.Utilities
|
||||
public class PreferencesManager
|
||||
{
|
||||
private readonly Dictionary<Type, Preferences> preferenceList;
|
||||
public string SavePath;
|
||||
string savePath;
|
||||
XmlSerializer xmlSerializer;
|
||||
|
||||
public PreferencesManager(string savePath, params Preferences[] preferences)
|
||||
{
|
||||
this.SavePath = savePath;
|
||||
this.savePath = savePath;
|
||||
Directory.CreateDirectory(savePath);
|
||||
preferenceList = new Dictionary<Type, Preferences>();
|
||||
|
||||
Type[] preferenceTypes = new Type[preferences.Length];
|
||||
@ -56,10 +58,10 @@ namespace RhythmBullet.Zer01HD.Utilities
|
||||
|
||||
private bool LoadSpecific(Type preference)
|
||||
{
|
||||
string path = SavePath + "/" + preference.Name;
|
||||
string path = savePath + "/" + preference.Name;
|
||||
if (File.Exists(path))
|
||||
{
|
||||
Stream stream = new FileStream(SavePath + "/" + preference.Name, FileMode.Open);
|
||||
Stream stream = new FileStream(savePath + "/" + preference.Name + ".xml", FileMode.Open);
|
||||
preferenceList[preference] = (Preferences)xmlSerializer.Deserialize(stream);
|
||||
stream.Close();
|
||||
return true;
|
||||
@ -69,7 +71,7 @@ namespace RhythmBullet.Zer01HD.Utilities
|
||||
|
||||
private void SaveSpecific(Type preference)
|
||||
{
|
||||
Stream stream = new FileStream(SavePath + preference.Name, FileMode.Create);
|
||||
Stream stream = new FileStream(savePath + "/" + preference.Name + ".xml", FileMode.Create);
|
||||
xmlSerializer.Serialize(stream, preferenceList[preference]);
|
||||
stream.Close();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user