Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Verifying whether  the file is opened before deleting

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

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
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…
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…
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…

809 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