yoy.be "Why-o-Why"

Reading 'locked' files with TFileStream fails.

2006-06-15 13:55  i656  delphi  [permalink]

On some files, the system keeps a 'read lock' for the time the file is in use (e.g. an executable that is running). This prevents making changes to the file, but reading is still possible.

Except when using TFileStream.Create('...',fmOpenRead);

Apparently, the fmOpenRead flag, does require full access to the file, even if you won't be writing to the file over the stream...

To let the system know you won't be writing (or you want to allow writing), specify the fmShareDenyWrite (or fmShareDenyNone) flag also: TFileStream.Create('...',fmOpenRead or fmShareDenyNone);.


twitter reddit linkedin facebook