mirror of
https://github.com/ShareX/ShareX.git
synced 2024-07-04 22:21:23 +12:00
When loading setting set FilePath for new SettingsBase
This commit is contained in:
parent
df60a0db7e
commit
ffead0104a
|
@ -36,7 +36,7 @@ public abstract class SettingsBase<T> where T : SettingsBase<T>, new()
|
|||
private static readonly SerializationType SerializationType = SerializationType.Json;
|
||||
|
||||
[Browsable(false)]
|
||||
public string FilePath { get; private set; }
|
||||
public string FilePath { get; set; }
|
||||
|
||||
[Browsable(false)]
|
||||
public string ApplicationVersion { get; set; }
|
||||
|
|
|
@ -57,9 +57,9 @@ public static bool Save(object obj, string filePath, SerializationType type, boo
|
|||
{
|
||||
lock (obj)
|
||||
{
|
||||
string tempFilePath = filePath + ".temp";
|
||||
Helpers.CreateDirectoryIfNotExist(filePath);
|
||||
|
||||
Helpers.CreateDirectoryIfNotExist(filePath, true);
|
||||
string tempFilePath = filePath + ".temp";
|
||||
|
||||
using (FileStream fs = new FileStream(tempFilePath, FileMode.Create, FileAccess.Write, FileShare.Read))
|
||||
{
|
||||
|
@ -118,7 +118,7 @@ public static void Save(object obj, Stream stream, SerializationType type)
|
|||
}
|
||||
}
|
||||
|
||||
public static T Load<T>(string path, SerializationType type, bool checkBackup = true) where T : new()
|
||||
public static T Load<T>(string path, SerializationType type, bool checkBackup = true) where T : SettingsBase<T>, new()
|
||||
{
|
||||
string typeName = typeof(T).Name;
|
||||
|
||||
|
@ -157,7 +157,7 @@ public static T Load<T>(string path, SerializationType type, bool checkBackup =
|
|||
|
||||
DebugHelper.WriteLine("{0} not found. Loading new instance.", typeName);
|
||||
|
||||
return new T();
|
||||
return new T() { FilePath = path };
|
||||
}
|
||||
|
||||
public static T Load<T>(Stream stream, SerializationType type)
|
||||
|
|
Loading…
Reference in a new issue