Following statement runs fine under Delphi XE (Windows 7 x64) but gives "Exception class EFOpenError with message..." under Delphi XE3 (Windows 7 x64). It looks like a bug. If so, is there a workaround?

      TFileStream.Create(
        'C:\Test.txt'
        , fmOpenRead,
//        FILE_SHARE_READ);
//        FILE_SHARE_WRITE);
        FILE_SHARE_READ or FILE_SHARE_WRITE);
1

There are 1 answers

4
kludg On BEST ANSWER

Use fmShareDenyNone constant instead of FILE_SHARE_READ or FILE_SHARE_WRITE:

 TFileStream.Create(
    'C:\Test.txt', fmOpenRead or fmShareDenyNone);

it is not a bug. See Documentation for details.