From 282cc97fffa06a99207ed73ac03b846260ff2c7e Mon Sep 17 00:00:00 2001 From: "leon.hoppe" Date: Tue, 12 Sep 2023 08:11:41 +0200 Subject: [PATCH] fixed strange file writing issues --- BetterIServ.Backend/Controllers/StorageController.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/BetterIServ.Backend/Controllers/StorageController.cs b/BetterIServ.Backend/Controllers/StorageController.cs index dbc4716..af8e624 100644 --- a/BetterIServ.Backend/Controllers/StorageController.cs +++ b/BetterIServ.Backend/Controllers/StorageController.cs @@ -16,9 +16,8 @@ public class StorageController : ControllerBase { var file = new FileInfo($"/data/{user}/{item}.json"); if (file.Directory?.Exists != true) file.Directory?.Create(); - - await using var stream = file.Exists ? file.OpenWrite() : file.Create(); - await stream.WriteAsync(Encoding.UTF8.GetBytes(data)); + await System.IO.File.WriteAllTextAsync(file.FullName, data, Encoding.UTF8); + return Ok(); }