I have figured out how to write and read to a file with the StreamReader and StreamWriter, but I am bit lost on how to erase all the contents from within the file.
Can anyone help me with this little problem? Thanks in advance!
I have figured out how to write and read to a file with the StreamReader and StreamWriter, but I am bit lost on how to erase all the contents from within the file.
Can anyone help me with this little problem? Thanks in advance!
Do you want to overwrite the contents of the file (i.e. delete all contents and write new entries), or just clear out the file and leave it at 0bytes(in which case I’d suggest just using File.Delete())?
If it’s Overwrite, when opening up a FileStream, there is an optional FileMode option (FileMode Enum (System.IO) | Microsoft Learn), and FileMode.Create will delete the contents and you start writing from scratch each time.
Awww… it’s File.Delete() that I am looking forward. I knew it was something I easily overlooked. Thanks!