Lennie and Vahan, ----- Original Message ----- From: "louis" <[EMAIL PROTECTED]> To: <[email protected]> Sent: Wednesday, May 25, 2005 11:35 AM Subject: [list] RE: [delphi-en] Checking If File Is In Use?
> Delphi will raise an exception if the file is in use. Can't recall the > exception class right now. Yes, so (at the risk of stating the obvious), you simply try to open the file in the desired mode you want it and catch/deal with the exception that is raised in a try/except block if the operation fails. Note: The problem with logic that uses a function that tells you whether a file is in use at the present moment in time is that the code that follows it can never be 100% sure that the file is still available at the moment when you open it since some other process might've locked the file in between you checking whether it's available and you actually opening the file. Thus, your code might fail over unexpectedly if you depend on a "IsTheFileAvailable" type function unless you also deal with the eventuality I've described. Which means, you might as well not bother with "IsTheFileAvailable" in the first place and just attempt to open the file directly, and just deal with the case where it isn't available as appropriate (e.g., report it to the user, or wait and try again, or whatever) which of course involves catching the exception. Regards Walter ----------------------------------------------------- Home page: http://groups.yahoo.com/group/delphi-en/ To unsubscribe: [EMAIL PROTECTED] Yahoo! Groups Links <*> To visit your group on the web, go to: http://groups.yahoo.com/group/delphi-en/ <*> To unsubscribe from this group, send an email to: [EMAIL PROTECTED] <*> Your use of Yahoo! Groups is subject to: http://docs.yahoo.com/info/terms/

