How does one clear the contents of a file?
Empty or delete the contents of a large file using the truncate command in the Linux/Unix system. The truncate command is used to shrink or extend the size of a file to a specified size in the Linux system. It is also used to empty large file contents by using the -s option followed by 0 (zero) specified size.
You can use truncate. Save this answer.
You can use the File.WriteAllText method.
System.IO.File.WriteAllText(@"Path/foo.bar",string.Empty);
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With