handle writing files better
This commit is contained in:
parent
987a28c747
commit
82c666296a
1 changed files with 7 additions and 7 deletions
|
@ -203,11 +203,11 @@ namespace Buypeeb {
|
||||||
if (!Directory.Exists(this.location)) {
|
if (!Directory.Exists(this.location)) {
|
||||||
Directory.CreateDirectory(this.location);
|
Directory.CreateDirectory(this.location);
|
||||||
}
|
}
|
||||||
if (!File.Exists(p)) {
|
|
||||||
var fs = File.CreateText(p);
|
using (StreamWriter fs = File.CreateText(p)) {
|
||||||
fs.Close();
|
fs.Write(j);
|
||||||
}
|
}
|
||||||
File.WriteAllText(System.IO.Path.Combine(this.location, "userdata.json"), j);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateThread(string id) {
|
private void UpdateThread(string id) {
|
||||||
|
@ -529,10 +529,10 @@ namespace Buypeeb {
|
||||||
if (sd.Run() == (int)ResponseType.Accept) {
|
if (sd.Run() == (int)ResponseType.Accept) {
|
||||||
try {
|
try {
|
||||||
if (!File.Exists(sd.Filename)) {
|
if (!File.Exists(sd.Filename)) {
|
||||||
var fs = File.CreateText(sd.Filename);
|
using (StreamWriter fs = File.CreateText(sd.Filename)) {
|
||||||
fs.Close();
|
fs.Write(JsonSerializer.Serialize(this.settings, jsonOptions));
|
||||||
|
}
|
||||||
}
|
}
|
||||||
File.WriteAllText(sd.Filename, JsonSerializer.Serialize(this.settings, jsonOptions));
|
|
||||||
}
|
}
|
||||||
catch (Exception e) {
|
catch (Exception e) {
|
||||||
Console.WriteLine(e);
|
Console.WriteLine(e);
|
||||||
|
|
Loading…
Reference in a new issue