When saving the config file - check if the file is read-only first, if it is, don't try to save

This commit is contained in:
adelikat 2014-08-03 15:51:08 +00:00
parent d047e1f45c
commit ac7f1ff7eb
1 changed files with 6 additions and 3 deletions

View File

@ -59,10 +59,13 @@ namespace BizHawk.Client.Common
public static void Save(string filepath, object config) public static void Save(string filepath, object config)
{ {
var file = new FileInfo(filepath); var file = new FileInfo(filepath);
using (var writer = file.CreateText()) if (file.Exists && !file.IsReadOnly)
{ {
var w = new JsonTextWriter(writer) { Formatting = Formatting.Indented }; using (var writer = file.CreateText())
Serializer.Serialize(w, config); {
var w = new JsonTextWriter(writer) { Formatting = Formatting.Indented };
Serializer.Serialize(w, config);
}
} }
} }