On Wed, 23 Apr 2008 14:52:44 -0700, Michael A. Covington
<lo**@www.covingtoninnovations.com.for.addresswrot e:
[...]
Since the loading and saving are done at different times (at least
minutes
apart) by the same person, I don't see how it could be a race condition.
I don't either. But then, the above is of course a simplification of
what's really going on. It could be that with a concise-but-complete code
sample, an actual problem could be identified. Of course, I suspect that
if you had such a sample and you knew how to get it to misbehave, you
wouldn't be asking the question. :)
Is there some error condition that could result in a zero-length file
(either reading or writing) without throwing an exception?
I should hope not. I admit, I don't know with 100% certainty, but my
approach to an OS API, Windows included, is that it will do exactly what I
tell it to, unless it tells me otherwise. No error implies it completed
the operation I asked for.
The problem has some characteristics of failing to properly flush/close
your output stream, but a) that doesn't explain why the file would show up
with data later on (i.e. when the user goes to email the file to you), and
b) at least in the simplified version you posted, everything appears to be
fine with respect to making sure the output stream is closed.
So I guess I'm out of guesses. Sorry.
One thing you might try is delivering a version of your program with some
instrumentation in it. Have it log user actions, and perhaps also do some
double-checking when the file's written to make sure it winds up the
length you expect (i.e. 0). Heck, you might even write to a
MemoryStream instead, and then do some verification on the length of the
resulting string, as well as making sure that the file written matches the
length and contents of the MemoryStream. That way the file i/o has some
double-checking in it.
Other than that, it's pretty much a mystery to me. :)
Pete