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)) {
|
||||
Directory.CreateDirectory(this.location);
|
||||
}
|
||||
if (!File.Exists(p)) {
|
||||
var fs = File.CreateText(p);
|
||||
fs.Close();
|
||||
|
||||
using (StreamWriter fs = File.CreateText(p)) {
|
||||
fs.Write(j);
|
||||
}
|
||||
File.WriteAllText(System.IO.Path.Combine(this.location, "userdata.json"), j);
|
||||
|
||||
}
|
||||
|
||||
private void UpdateThread(string id) {
|
||||
|
@ -529,10 +529,10 @@ namespace Buypeeb {
|
|||
if (sd.Run() == (int)ResponseType.Accept) {
|
||||
try {
|
||||
if (!File.Exists(sd.Filename)) {
|
||||
var fs = File.CreateText(sd.Filename);
|
||||
fs.Close();
|
||||
using (StreamWriter fs = File.CreateText(sd.Filename)) {
|
||||
fs.Write(JsonSerializer.Serialize(this.settings, jsonOptions));
|
||||
}
|
||||
}
|
||||
File.WriteAllText(sd.Filename, JsonSerializer.Serialize(this.settings, jsonOptions));
|
||||
}
|
||||
catch (Exception e) {
|
||||
Console.WriteLine(e);
|
||||
|
|
Loading…
Reference in a new issue