Solved

Verifying whether  the file is opened before deleting

Posted on 1998-08-17
3
129 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

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

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…
You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

760 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

21 Experts available now in Live!

Get 1:1 Help Now