Does Rewrite clear file contents of existing file or does it delete it and create a new one?
I have a text file in my app.exe folder which I need to clear. Any example?
Does Rewrite clear file contents of existing file or does it delete it and
Share
From the Delphi XE2 documentation, topic Rewrite – read the last quoted paragraph:
From the same documentation, link at the bottom of page for
System.Rewrite, modified to use your app’s folder:You should know, though, that
Rewriteis outdated and doesn’t support Unicode. You should be using more modern methods to read and write files like TFileStream or TStringWriter (or even the simple solution of TStringList).Note that you cannot use
TStrings; it’s an abstract class. You need to use one of it’s descendants instead (TStringListis the one used most often).