Search the web
Sign In
New User? Sign Up
vbra · Visual Basic - Reliable Answers
? Already a member? Sign in to Yahoo!

Yahoo! Groups Tips

Did you know...
Message search is now enhanced, find messages faster. Take it for a spin.

Best of Y! Groups

   Check them out and nominate your group.
Having problems with message search? Fill out this form to ensure your group is one of the first to be migrated to the new message search system.

Messages

  Messages Help
Advanced
Querying file state   Message List  
Reply | Forward Message #12 of 42 |
RE: [VBra] Querying file state

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






Thu Jul 26, 2001 6:43 am

vb@...
Send Email Send Email

Forward
Message #12 of 42 |
Expand Messages Author Sort by Date

Hi, there Shawn, 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...
Marcos
astillax@...
Send Email
Jul 26, 2001
12:07 am

Hi Marcos, ... You can do it several ways. Something as simple as this could work: (warning - vaporcode) '// ============================================ ...
Shawn K. Hall
vb@...
Send Email
Jul 26, 2001
6:41 am
Advanced

Copyright © 2009 Yahoo! Inc. All rights reserved.
Privacy Policy - Terms of Service - Guidelines - Help