Reputation: 1085
I need write a very big file (about 100-150 mb) with Delphi. This file will be a CSV file or a SQL file (the user can choose it).
In the past I always use a TStringList object to write text files but in this case I have a very big file and I think this is not the best solution. I need a speed and low memory solution if possible.
Upvotes: 0
Views: 1401
Reputation: 596101
Use a TFileStream
and write your output data to it as you are creating the data. That way, you are writing to the file immediately and it grows accordingly, and you are not wasting memory.
If you are using Delphi 2009 or later, you can use the TStreamWriter
class to wrap the TFileStream
. TStreamWriter
has Write()
and WriteLine()
methods for writing String
and formatted data.
Upvotes: 3