• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 302
  • Last Modified:

File already open or not

How do I determine if a file has already been opened by another user?

I have tried using GetAttr(filename)but it is not giving me the correct answer, ie 1.
0
GNCstar
Asked:
GNCstar
  • 2
  • 2
1 Solution
 
AzraSoundCommented:
You could do something like:

Open strFile For Output Lock Write As #1

And catch error 55 "File already open"
0
 
GNCstarAuthor Commented:
AzraSound,

I have tried that but the code stops with Run-time error '70': Permission denied.
0
 
AzraSoundCommented:
Yes, I think Permission Denied is actually what you get.  It should be reliable for nearly all cases, though, I think it is possible to get that error if you are trying to access a file that you do not have the rights to for writing.  In addition, it should be changed to Lock Read Write instead of just Lock Write.
0
 
GNCstarAuthor Commented:
Cheers, I can see why you are the number 1.
0

Featured Post

Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now