C
C#2y ago
Rohan

❔ 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
Angius
Angius2y ago
Just write an empty string
mtreit
mtreit2y ago
What @Angius said...but why?
ChucklesTheBeard
also take a look at the various FileMode options; Truncate is probably of interest
Rohan
RohanOP2y ago
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
Angius
Angius2y ago
Serialize the object to a string Save string in a file await File.WriteAllTextAsync("filename.json", theJsonString) for example
Rohan
RohanOP2y ago
Oh..if u give WriteAllText a filename that exists, does it overwrite it?
Angius
Angius2y ago
Yeah
Rohan
RohanOP2y ago
Ohhhhhhh Im stupid Thanks
Accord
Accord2y ago
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.
Want results from more Discord servers?
Add your server