When I first saw the System.IOUtils
unit with functions like TFile.ReadAllBytes
and TFile.ReadAllText
and the TStreamReader
and TBinaryReader
classes in System.Classes
I was quite excited to have easy ways to read binary and text files.
After using them for a while I noticed that the default share mode is implicitly fmShareCompat
, since they all use TFileStream.Create
, but do not explicitly specify a share mode.
Since fmShareCompat
is treated as fmShareExclusive
on Windows this leads to file locking problems when using them.
Is this an oversight by the Delphi developers? Or is there a reason to not use fmShareDenyWrite
by default?
Also why is there no way to specify a share mode?
I am now tempted to write my own version of these classes in order to make them more sharing friendly.