Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Checking for open files

Status
Not open for further replies.

BuckBMD

MIS
Mar 15, 2001
13
US
Does anyone know of a script to check for any open files within a given directory? Perhaps an API call is required.

Thanks in advance for any assistance you can offer.
 
Hello BudBMD,

[1] If some application is operating in such a way that it loads a file into memory in its entirety and processes it from there, the original file sitting on the storage device will be freely available as if nothing happened to it. That means you cannot tell by checking the file on the storage device whether a duplicate of it is being used somewhere in the memory by some application. The only hint would be its DateLastAccessed Property.

[2] If some application locks the file and partially load it in the memory due to its size or ownership of it in a multiuser environment, you can check whether the file on the storage device still has a writeable property. It can be done by fso opening it for Appending [opentextfile(thefile,forAppending)] with an error trapping under On Error Resume Next declared. If the process throws an error you can be sure it is being used. Once this error, positive or negative, is monitored, close the file object immediately after.

regards - tsuji
 
Thanks for the response. This will probably work. I also found two (2) APIs that I can use to accomlish it as well.

Again, thanks for the advice!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top