[fpc-pascal] TFileStream.SetSize sometimes fails

Mattias Gaertner nc-gaertnma at netcologne.de
Thu Aug 13 21:23:16 CEST 2009


I want to replace the content of an existing file (keeping the type and
rights). I used:

fs := TFileStream.Create(Filename, fmOpenWrite or fmShareDenyNone);
fs.Size := 0;
fs.Write(.....);
fs.Free;

But it does not always work. The line fs.Size does not clear the file on
every file system. So the fs.Write only replaces the first part of the
file.

See http://bugs.freepascal.org/view.php?id=13931

Any idea, what to do instead?

Mattias




More information about the fpc-pascal mailing list