Announcement

Collapse
No announcement yet.

Error 70 on reading file

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Error 70 on reading file

    I keep getting error 70 (Permission denied) when reading from a file.

    I have several processes running (all PBDLL6 applications).
    One process writes to some files, then closes them and posts an
    interprocess message to alert the other processes. They respond
    by attempting to read the changed data from the files. Some of
    them load the data ok but some fail with error 70.

    I thought it was ok in Win32 for more than one process to read
    from a file at the same time or am I wrong on that?

    I intend to get into synchronization later, but I thought it
    would not be necessary with the above outlined scheme.

    Keith Waters

    ------------------

  • #2
    Did you open it shared?

    Add: LOCK SHARED

    ------------------
    [email protected]
    hellobasic

    Comment


    • #3
      Edwin

      Thanks for prompting me to try LOCK SHARED. It seems to have
      done the trick. All works fine now.

      I'd looked at the PB documentation for the OPEN statement and
      seen LOCK SHARED but didn't realise it was neccessary for what
      I'm trying to do. I still don't understand why I have to use
      any form of file locking when all I'm doing, after the original
      write has completed, is to read from the file. I'm not trying
      to read and write which is what the documentation says LOCK SHARED
      allows.

      Anyway, many thanks
      Regards Keith

      ------------------

      Comment


      • #4
        Keith,
        The operating system has to be signalled as to how you want file
        operations to be handled. PowerBasic defaults to allowing only a
        single opening for a file. This prevents another process from
        modifying the file you are working on unless you expressly permit it.

        When referring to LOCK, the OPEN command is referring to what
        OTHER processes will be permitted to do. The deault is LOCK READ WRITE
        which locks other operations from any access. If another process attempts
        to open an already open file, then you get error 70 - permission denied.

        You have to expressly permit access. If you only want other processes to
        READ your file, then lock them out of writing with LOCK WRITE. If you want
        to permit Reads and Writes, then use LOCK SHARED. I am not sure why you
        would use LOCK READ, but it is still there to allow a process to WRITE to
        your file without reading it.

        Clear as mud?

        Regards,

        ------------------
        [email protected]
        :) IRC :)

        Comment


        • #5
          Ian

          Not clear as mud, crystal clear. It's just that I did not
          understand the default. You have explained it for me.

          Many thanks.

          Keith

          ------------------

          Comment

          Working...
          X