Solved

file locking

Posted on 2002-05-07
5
176 Views
Last Modified: 2010-05-02
I need to establish whether a file is locked by another user.
0
Comment
Question by:DAVIDW
5 Comments
 
LVL 43

Expert Comment

by:TimCottee
ID: 6993735
What sort of a file?
0
 

Author Comment

by:DAVIDW
ID: 6993753
A TEXT FILE
0
 
LVL 43

Accepted Solution

by:
TimCottee earned 100 total points
ID: 6993762
This is not necessarily as simple as it may seem, a text file may be opened for reading without placing a lock on the file. The best thing to do is basically attempt to place a lock on the file of the type that you require:

On Error Resume Next
Open "MyFile.txt" For Binary Access Write As #1
If Err.Number <> 0 Then
  Msgbox "Error locking file"
Else
  Close #1
End If

This will basically attempt to open the file for binary write. If it succeeds then you can be fairly certain that the file is not locked by any other user.

0
 
LVL 49

Expert Comment

by:DanRollins
ID: 7722352
Hi DAVIDW,
It appears that you have forgotten this question. I will ask Community Support to close it unless you finalize it within 7 days. I will ask a Community Support Moderator to:

    Accept TimCottee's comment(s) as an answer.

DAVIDW, if you think your question was not answered at all or if you need help, just post a new comment here; Community Support will help you.  DO NOT accept this comment as an answer.

EXPERTS: If you disagree with that recommendation, please post an explanatory comment.
==========
DanRollins -- EE database cleanup volunteer
0
 

Expert Comment

by:SpideyMod
ID: 7780044
per recommendation

SpideyMod
Community Support Moderator @Experts Exchange
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Child Form in front 4 56
pop out of webbrowser1 control vba6 5 41
which modules are active in VB6 project? 6 51
VBA: Insert New column with specific format type 12 54
Introduction In a recent article (http://www.experts-exchange.com/A_7811-A-Better-Concatenate-Function.html) for the Excel community, I showed an improved version of the Excel Concatenate() function.  While writing that article I realized that no o…
I was working on a PowerPoint add-in the other day and a client asked me "can you implement a feature which processes a chart when it's pasted into a slide from another deck?". It got me wondering how to hook into built-in ribbon events in Office.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question