Results 1 to 3 of 3

Thread: detecting if a file is opened by any other app.

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    The Netherlands
    Posts
    112

    detecting if a file is opened by any other app.

    Hi there,

    Is there a way to determine if a file is opened by any (other) application in windows? And if so; is there also a way to force the file to be closed?

    The problem i have is this: The prog i made runs on multiple workstations on a LAN and since im a novice at this, the prog crashes regularly (for now). When it does, it often leaves a certain txtfile opened (on the server). which causes other copies of the prog to crash or stop as well, because it cant write/rename the opened txtfile.

    Thanks in advance for the help!

    Remvs
    The NEtherlands

  2. #2
    jim mcnamara
    Guest
    This is part of the distributed lock management system.
    Locks are maintained locally on the PC that makes read/write/open requests to the server, but the server also has a lock table. If the PC dies, the server can remember the lock.

    If this is a problem do this in your code:

    Open the file, read all the records. CLose the file, do not leave it open. If you have to, keep track of where you are in the file, and then do periodic open, read, reset whereAmIInTheFile pointer, close the file.

    If you have to update the file, save the updates 'til the user requests a save, then dump it all out there.

    In any event do not leave the file open, just hit it, close it and run.

  3. #3

    Thread Starter
    Lively Member
    Join Date
    Apr 2001
    Location
    The Netherlands
    Posts
    112
    I , more or less, do it like this. But the problem is that it the error occurs when i write to /rename the file. I think i should just take care of that error instead of trying to close it by force after the error

    So, as far as you know, there is no way to determine or close a opened file??

    Thankx for your help Jim

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width