Re: Try..Except fails. Also - any other ways?



So without compilation and recrashing my application - what made you
determine the mode? this bitwised 'or'ed values - do you just kind of
guess from the individual functionality of each mode value that when
or'ed together they will combine their ability?

Mainly though - the fmShareExlusive states: Other applications can not
open the file for any reason.

What happens if this is already open by another application.. as is the
case - you see, the file i'm testing on - a log file, is getting logged
to by another application, but you can open this file with Notepad. It
just means you cannot save the file becaues it is currently in use by
another program (and if closed and reopened, it will have a whole new
buffer of log in it that was being created while you were viewing it).
This is of course fine. I'm just wanting to get the size of the file
that's being used with the TFileStream using this method, and not have
it fail, or if it does fail - for this to be handled.

Btw - Any ideas why the catch-all exception handling didn't work either
though? I suppose there could be no exception created for such an
occurance..

THanks, Adam.

J French wrote:
On 26 Jul 2006 21:50:39 -0700, "AdamMaynard24"
<adammaynard24@xxxxxxxxxxx> wrote:

I'm trying to load a log file into a TFileStream, but the problem is, I
don't have a way of checking if the log file is being used by another
application. Any ideas? I thought catching all exceptions would work:

I would use FileOpen

Then, if successful pass the Handle to a THandleStream

You will get a 'bad' Handle -1 if FileOpen fails

The mode you need is : fmShareExclusive Or fmOpenRead

.



Relevant Pages

  • Re: Benefits of Dynamic Typing
    ... The latter problem is detected in parts not specific to the compiler, ... and the only information about the reason is carried by the exception ... the entire Map call fails with the same exception. ... but it did expect that some application might fail. ...
    (comp.lang.functional)
  • Re: IllegalArgumentException vs. NullPointerException and collection behavior
    ... There is an advantage to declaring a checked exception - it forces client programmers to pay attention to it. ... The trouble with throwing any RuntimeException is that the API clients might fail abruptly because their programmers didn't pay close enough attention to the Javadocs. ... Throw a checked Exception if the client should have been able to count on getting a result, and you want to force awareness of any out-of-band problems. ...
    (comp.lang.java.help)
  • Problem with mysql api calls.
    ... read a log file, locate files described in that log file and fill in a ... interval short, to one minute, it would fail in a couple of hours. ... but fixing it didn't have any effect on the failure. ... fact the heartbeat update is being done to one and the failure is on the ...
    (comp.lang.cpp)
  • Re: INVALID_HANDLE_VALUE vs. NULL
    ... 0 (zero) can never be a valid handle value. ... Of course, ReadFilewill fail with this handle, ... > CloseHandle() does indeed fail when given a bad handle. ... > case it raises an exception. ...
    (microsoft.public.win32.programmer.kernel)
  • File I/O Exception: The Process Cannot Open The File...
    ... App 1 is an asp.net Web application that is installed multiple times on the ... same server (one installation per Web site hosted on the server). ... exception per file (so 5 runtime exceptions would result in 5 exception log ... When a new log file is found, ...
    (microsoft.public.dotnet.languages.csharp)