properly truncate file before writing
This commit is contained in:
parent
e2d59a54b7
commit
617ade0163
@ -66,9 +66,13 @@ namespace EliteBGS.Util {
|
||||
|
||||
public void SaveObjectives(Report report) {
|
||||
var serializer = JsonSerializer.CreateDefault();
|
||||
using (var file = new StreamWriter(File.OpenWrite(objectives_file), Encoding.UTF8)) {
|
||||
var stream = new JsonTextWriter(file);
|
||||
serializer.Serialize(stream, report.Objectives);
|
||||
using (FileStream filestream = File.OpenWrite(objectives_file)) {
|
||||
filestream.SetLength(0);
|
||||
filestream.Flush();
|
||||
using (StreamWriter file = new StreamWriter(filestream, Encoding.UTF8)) {
|
||||
JsonTextWriter stream = new JsonTextWriter(file);
|
||||
serializer.Serialize(stream, report.Objectives);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user