Solved

Locked files

Posted on 1998-07-29
1
194 Views
Last Modified: 2010-05-03
Is there a way to detect if a file is locked (in use)
0
Comment
Question by:dgb
1 Comment
 
LVL 14

Accepted Solution

by:
waty earned 50 total points
ID: 1467194
Function CheckOpenFile(sFile as String) as Boolean

   Dim nFile As Integer

   nFile = FreeFile

   on error goto Error_Read

   Open sFile For Input Lock Read As #nFile
   Close #nFile

   CheckOpenFile = False

   Exit Function
Error_Read:
   if Err = 70 then
      msgbox "File already open"
   End If

   close #nFile
   
   CheckOpenFile = True

   Exit Function

End Sub
0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction While answering a recent question (http://www.experts-exchange.com/Q_27402310.html) in the VB classic zone, I wrote some VB code in the (Office) VBA environment, rather than fire up my older PC.  I didn't post completely correct code o…
If you need to start windows update installation remotely or as a scheduled task you will find this very helpful.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

708 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

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now