Re: File IO-I am defeated!



"PeterD" <peter2@xxxxxxxxxx> wrote in message news:shfes31o6s7m2537pe2lnlks89sl1jl0sl@xxxxxxxxxx

Again if I had access to the file I could fix it, my problem
is that it fails on user's machines that I have absolutely no
access to.

So add some code to trap the error and have the error routine run the code I posted in my last response, except change my code so that it send its output to a log file instead of to a ListBox. It only logs a total of 256 bytes, allowing you to analyse the content of the small log file in a way which will undoubtedly solve your problem.

[my posted test code snipped] Again... <g>

No. Not again <g>. If you actually look at the code I posted you will see it is quite different from the code I posted previously. This new code opens the suspect file and produces a list of exactly 256 bytes, with each of the 256 bytes telling you how many of that specific character code are in the file.

I've gotten good ideas from you and others which
I'll try out. It takes time, basically I have to write
'new' code, put it into production, and wait for run
time error statistics to be generated.

Yes. Exactly as I have decribed above. You are telling us that these files contain only "standard text characters", and that you have produced them using your own code so you are certain you are correct. But if you actually were correct then you would not ever get the specific error you have reported.

Your own code (the code you posted) will happily load a file containing whatever bytes values you wish, whether they are what you would call standard text characters or not, EXCEPT it will fail with exactly the error you describe if there is a Chr(0) or a Chr(26) anywhere in the file. I would bet my bottom dollar that when you eventually get the log back (as described above) from the faulty file you will find at least one of those characters in there, most probably the zero. Perhaps sometimes the file you are loading has been saved in Unicode format, which would still produce a text file that can be read by most modern text editors but one which would fail to load with the code you are currently using, because it is half full of zeros. Or, more likely, something is placing a stray 26 or zero in the file, perhaps a "trailing zero" at the end of one or more text strings produced by some C code and where your code that wrote the file failed to remove the trailing zero.

The turn around time remindes me of my days in grad
school when we used punch cards, and often would not
see results for a day! You remember: the good old days!

I certainly do ;-)

Mike



.



Relevant Pages

  • Re: How to destroy Leopard/Vista/Dragon, all at one fell swoop
    ... I prefer to use words to get across meaning, as in "hex zero", which is ... winded technical explanation about characters, bytes, numbers, ... Try explaining "hex notation" to an unknowledgeable reader, ...
    (comp.sys.mac.system)
  • 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)
  • Re: INVALID_HANDLE_VALUE vs. NULL
    ... > On any NT-derived platform, 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. ...
    (microsoft.public.win32.programmer.kernel)
  • Re: quality control
    ... Almost always, zero. ... will be, on the average, only 1 bad item in 100 samplings -- ... You expect 1 failure in 10,000. ... I'm thinking with the binary outcome of fail/not fail, ...
    (sci.stat.math)