An easier solution is to try to open the file exclusively. If it fails, one of the errors will be unable to obtain the exclusive lock (because the file is open already).
From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Steve Howard (PFE) Sent: Thursday, February 18, 2010 10:34 AM To: Jason Lowder; perl-win32-users@listserv.ActiveState.com Subject: RE: Determining if a file is open Excuse me for being in a rush and not having time to develop a sample, but I think what you want to do can be determined using WMI, in the CIM_Datafile class, there is a property named InUseCount: http://msdn.microsoft.com/en-us/library/aa387236(VS.85).aspx http://www.slideshare.net/ddn123456/win32-perl-wmi (Haven't checked that one out, but it says it is an introduction to using Perl and WMI) http://forums.cacti.net/about5816.html (Contains an example of using WMI in Perl). Almost all properties of windows objects can be found in some WMI class. You can also connect to remote machines and run WQL queries against those machines, so it is not just for local machines. If needed, I'll see if I can provide an example when I get off work today. Hopefully, this gets you going in the right direction. From: perl-win32-users-boun...@listserv.activestate.com [mailto:perl-win32-users-boun...@listserv.activestate.com] On Behalf Of Jason Lowder Sent: Thursday, February 18, 2010 7:20 AM To: perl-win32-users@listserv.ActiveState.com Subject: Re: Determining if a file is open And yes, this is under Windows. (Vista) Jason On 2/18/2010 8:38 AM, Jason Lowder wrote: Hello, Is there anyway to determine if a file is currently open by another process? I want to look at a file that is being generated by another program (sometimes a very large file) and determine when it is finally closed. I see the file attributes for things like size, owner, type etc. but nothing to really determine it's state. Thanks, Jason _______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs No virus found in this incoming message. Checked by AVG - www.avg.com Version: 9.0.733 / Virus Database: 271.1.1/2693 - Release Date: 02/17/10 01:35:00
_______________________________________________ Perl-Win32-Users mailing list Perl-Win32-Users@listserv.ActiveState.com To unsubscribe: http://listserv.ActiveState.com/mailman/mysubs