Solved

Verifying whether  the file is opened before deleting

Posted on 1998-08-17
3
131 Views
Last Modified: 2010-04-30
I have a situation in which I am deleting a file using Kill(Path), but before deleting the file I need to check whether the file is opened by user through another application so that I can prompt the user that the file is in use before deleting. How can I achieve it.

Briefly how can I check whether the file is opened by some other application. File may be of any extension like .xls, .doc, .txt.
0
Comment
Question by:lesa
  • 2
3 Comments
 
LVL 14

Accepted Solution

by:
waty earned 10 total points
ID: 1429261
You can open the file as lock before killing it :
Open "TESTFILE" For Binary Access Read Lock Read Write As #1
0
 

Author Comment

by:lesa
ID: 1429262
Sorry for the delayed response. I don't want to open the file, I just want to delete the file and before that I need to verify if the file is being used by some other application so that I an propmt the user to close the file before deleting.
0
 
LVL 14

Expert Comment

by:waty
ID: 1429263
This is the only solution. To know if the file is open, you need to access it. There is nowhere a property set telling that the file is currently openend.
0

Featured Post

Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

Question has a verified solution.

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

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…
When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
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…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…

776 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