Clearing existing file
-
Hi guys,
Maybe just a trivial question, but I have to write some data to a file (and off course open it again later on). The problem I encounter is that when the file already exists the "old" data in the file will stay there when the new data (that overwrites this) is shorter then the old data. In QFile the only thing I could find is QFile.resize(0); I'm using a QTextStream to fill the data in the file.Are there any better ways of doing this? It does work, but IYAM it's not real pretty, or is it?
Greetz
-
[quote author="Sam" date="1359467461"]Try to open the file with QIODevide::Truncate flag.[/quote]
If the problem persists after that, try to remove the file before writing the new data.