Hi Marcos,
> You recently wrote on one of your feeds to another group:
>
> "...OTOH, if you're not using forms you might consider
> running a state loop checking to see if the main.exe is
> deleteable and replacing it after it is successfully
> removed..."
>
> What should I use to check if a file is deleteable?
> I assume it is not through error trapping.
You can do it several ways.
Something as simple as this could work:
(warning - vaporcode)
'// ============================================
Function ReallyKillFile(sFilename$)
On Error Resume Next
Dim dCancel as Date
' set a timeout value
dCancel = DateAdd("s", 10, Now)
While (Dir(sFilename)<>"") And (dCancel > Now)
Kill sFileName
Wend
ReallyKillFile = CBool(Dir(sFilename) = "")
End Function
'// ============================================
You could also use a more elaborate procedure in order to explicitly
trap for the error message (this is a good idea in order to prevent
read-only media errors).
I assume from your message that you would like to avoid raising an
error. Why?
You don't have to pass it up the chain, and without the ability to
trap for errors we would not be able to accomplish many of the
things we can within our applications. I think you'll find that most
developers use error trapping not as a "last resort" but as a
functional necessity for programming. Errors occur - and if you can
code for them correctly in the first place your code will be more
stable in the long run. Errors are an excellent way of determining
state of an application as well. And they are excellent sources for
events.
I'm dumbfounded when I see programmers trying diligently to "avoid
errors" by avoiding error trapping and error management, as though
that were a means of avoiding *coding* errors within their projects.
> Thanks a lot,
You're welcome.
> -Congrats for your new group and for your moderator
> "degree" in vbhelp
Thanks! :)
Regards,
Shawn K. Hall
http://ReliableAnswers.com