Hi,

I am looking for a (graceful) method to determine if a file is in use
(i.e., checking if i can delete or move it is *not* an option :) I am
already using the WMI to obtain a list of directories that I need to
check for the file (it is the same one for each directory), so perhaps
I could use that? Anyway, all suggestions are appreciated...

tia,
arno

Re: check if file is in use by Roland

Roland
Thu Mar 16 22:54:03 CST 2006

"arno" <rNOSPAMnospam@xs4all.nl> wrote in message
news:f6lj125k5s45dloism4q717bemcd0rtu14@4ax.com...
: I am looking for a (graceful) method to determine if a file is in use
: (i.e., checking if i can delete or move it is *not* an option :) I am
: already using the WMI to obtain a list of directories that I need to
: check for the file (it is the same one for each directory), so perhaps
: I could use that? Anyway, all suggestions are appreciated...

Have you tried setting:

On Error Resume Next
' process file (delete/move)
if err.number > 0 then
' process error
err.clear
end if
On Error Goto 0

--
Roland Hall
/* This information is distributed in the hope that it will be useful, but
without any warranty; without even the implied warranty of merchantability
or fitness for a particular purpose. */
Technet Script Center - http://www.microsoft.com/technet/scriptcenter/
WSH 5.6 Documentation - http://msdn.microsoft.com/downloads/list/webdev.asp
MSDN Library - http://msdn.microsoft.com/library/default.asp



Re: check if file is in use by arno

arno
Fri Mar 17 03:26:55 CST 2006

Roland, I now do it by trying to open the file as textfile for
appending; if that fails it's in use.

On Error Resume Next
Set oFile = oFSO.OpenTextFile(MyFile, ForAppending, False)
If Err.Number = 70 Then
'Permission denied error
IsFileLocked = True
Else
oFile.Close
IsFileLocked = False
End If
On Error GoTo 0

arno

On Thu, 16 Mar 2006 22:54:03 -0600, "Roland Hall" <nobody@nowhere>
wrote:

>"arno" <rNOSPAMnospam@xs4all.nl> wrote in message
>news:f6lj125k5s45dloism4q717bemcd0rtu14@4ax.com...
>: I am looking for a (graceful) method to determine if a file is in use
>: (i.e., checking if i can delete or move it is *not* an option :) I am
>: already using the WMI to obtain a list of directories that I need to
>: check for the file (it is the same one for each directory), so perhaps
>: I could use that? Anyway, all suggestions are appreciated...
>
>Have you tried setting:
>
>On Error Resume Next
>' process file (delete/move)
>if err.number > 0 then
> ' process error
> err.clear
>end if
>On Error Goto 0