Detecting File State

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • glen

    Detecting File State

    I'm looking for a way to detect if another process has a file open before a
    second process tries to open it. I've looked into the FileAttr function but
    I'm not sure if detecting a read-only state is sufficient. Can anyone
    confirm or deny? TIA...


  • Roger

    #2
    Re: Detecting File State

    > I'm looking for a way to detect if another process has a file open before
    a

    Make certain you know it exists, then,
    Try to open the file exclusively,
    an error means it is in use.
    Good day,
    Roger


    Comment

    • Michael Kellogg

      #3
      Re: Detecting File State

      "Roger" <roger@pcsreven uecontrol.com> wrote:
      [color=blue][color=green]
      >> I'm looking for a way to detect if another process has a file open
      >> before a[/color]
      >
      > Make certain you know it exists, then,
      > Try to open the file exclusively,
      > an error means it is in use.[/color]

      I'm not proposing a better solution, but I'm pretty sure using error-
      trapping or exception handling to test for a thoroughly possible condition
      like this would not qualify as a "best practice"...

      --
      Michael Kellogg

      Comment

      • Cor Ligthert

        #4
        Re: Detecting File State

        Glen,

        This is endless asked, however this is as long as there are the MS-dos
        operating systems and its successors not possible when you don't create a
        special management tool around it, as probably in Office is done.

        Cor


        Comment

        • glen

          #5
          Re: Detecting File State

          I have to agree. I'm thinking there must be a way to test the state of the
          file for this condition. I just haven't found anything yet...

          "Michael Kellogg" <mkellogg@WEDEL IVERcc3.com> wrote in message
          news:Xns96228D5 919534mkelloggW EDELIVERcc3@207 .46.248.16...[color=blue]
          > "Roger" <roger@pcsreven uecontrol.com> wrote:
          >[color=green][color=darkred]
          >>> I'm looking for a way to detect if another process has a file open
          >>> before a[/color]
          >>
          >> Make certain you know it exists, then,
          >> Try to open the file exclusively,
          >> an error means it is in use.[/color]
          >
          > I'm not proposing a better solution, but I'm pretty sure using error-
          > trapping or exception handling to test for a thoroughly possible condition
          > like this would not qualify as a "best practice"...
          >
          > --
          > Michael Kellogg[/color]


          Comment

          • glen

            #6
            Re: Detecting File State

            It's 'The eternal question', then...

            "Cor Ligthert" <notmyfirstname @planet.nl> wrote in message
            news:uOkCTLEMFH A.1176@TK2MSFTN GP15.phx.gbl...[color=blue]
            > Glen,
            >
            > This is endless asked, however this is as long as there are the MS-dos
            > operating systems and its successors not possible when you don't create a
            > special management tool around it, as probably in Office is done.
            >
            > Cor
            >[/color]


            Comment

            • Cor Ligthert

              #7
              Re: Detecting File State

              glen,

              Answers on this are

              do while loop condition = false
              Try
              Open a file
              When found leave set the condition to true
              Catch
              threading.threa d.sleep(1000)
              'And set a max if you want
              End

              I hope this helps something

              Cor


              Comment

              • glen

                #8
                Re: Detecting File State

                Interesting.... I'll try that. Thanks.

                "Cor Ligthert" <notmyfirstname @planet.nl> wrote in message
                news:uf5hMLIMFH A.3788@tk2msftn gp13.phx.gbl...[color=blue]
                > glen,
                >
                > Answers on this are
                >
                > do while loop condition = false
                > Try
                > Open a file
                > When found leave set the condition to true
                > Catch
                > threading.threa d.sleep(1000)
                > 'And set a max if you want
                > End
                >
                > I hope this helps something
                >
                > Cor
                >[/color]


                Comment

                Working...