Results 1 to 4 of 4

Thread: Checking if a file is open

  1. #1

    Thread Starter
    Addicted Member señorbadger's Avatar
    Join Date
    Oct 2003
    Location
    Mud pools of wellingborough
    Posts
    193

    Checking if a file is open

    Hi how can i check to see if a text file is being used by another application in VB6 ??

  2. #2
    Hyperactive Member
    Join Date
    May 2003
    Posts
    401
    May be this might help:

    There are a couple of tricks you can use.
    Try FileExist. In many cases FileExist will return a 2 if the file exists but is open in read-deny mode.

    VB Code:
    1. a=FileExist("yourfile")
    2. a==0 then no file.
    3. a==1 file exists. Looks OK.
    4. a==2 file exists. Not currently accessible.

    Try FileSize. If a file is open or being written to, FileSize will return a 0. File in use:
    Filesize==0

    Put the two of them together with:

    VB Code:
    1. While !FileExist("filename")
    2.        TimeDelay(1)
    3.     endwhile
    4.     While FileSize("filename")==0
    5.        TimeDelay(1)
    6.     endwhile
    Enjoy!!!
    apps_tech

  3. #3
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171


    Has someone helped you? Then you can Rate their helpful post.

  4. #4
    Super Moderator manavo11's Avatar
    Join Date
    Nov 2002
    Location
    Around the corner from si_the_geek
    Posts
    7,171


    Has someone helped you? Then you can Rate their helpful post.

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