❔ File IO Question.
Is there anyway to empty a json file? I know you can delete the file but is there anyway to empty all the json in the file instead of deleting it?
Thanks
9 Replies
Just write an empty string
What @Angius said...but why?
also take a look at the various FileMode options; Truncate is probably of interest
Like I wanna edit a json file
Using Newtonsoft
I figured out how to edit the jsonString
Now how do u edit the actual file
Thats my question
Serialize the object to a string
Save string in a file
await File.WriteAllTextAsync("filename.json", theJsonString)
for exampleOh..if u give WriteAllText a filename that exists, does it overwrite it?
Yeah
Ohhhhhhh
Im stupid
Thanks
Was this issue resolved? If so, run
/close
- otherwise I will mark this as stale and this post will be archived until there is new activity.