G
Guest
Hi,
I have a problem that seems to be a bug in the .NET Framework. If I create
a new FileStream on a media that has limited disk space (I use a diskette to
simulate the problem), the FileStream is effectively created. Small (smaller
than the buffer size) Writes to the buffer are also executed with no errors.
However, when I try to Flush the data, an IOException is thrown. I catch it
and in my finally block, I try to .Close() my stream which will in turn try
to Flush the data and another exception is thrown.
So, I tried putting a try/finally block in the first finally (!) and when
the Exception is thrown from the .Close() call, I decided that I could set my
FileStream to null (I know it leaks a handle, but lets my process run).
However, when the GC kicks in, it tries to close the FileStream which, you
guessed it, throws the same IOException again.
My solution was to finally remove the finalizer for the FileStream object at
that point but this is very ugly. is there a way to Close the FileStream in
that situation?
Thanks,
Joël
I have a problem that seems to be a bug in the .NET Framework. If I create
a new FileStream on a media that has limited disk space (I use a diskette to
simulate the problem), the FileStream is effectively created. Small (smaller
than the buffer size) Writes to the buffer are also executed with no errors.
However, when I try to Flush the data, an IOException is thrown. I catch it
and in my finally block, I try to .Close() my stream which will in turn try
to Flush the data and another exception is thrown.
So, I tried putting a try/finally block in the first finally (!) and when
the Exception is thrown from the .Close() call, I decided that I could set my
FileStream to null (I know it leaks a handle, but lets my process run).
However, when the GC kicks in, it tries to close the FileStream which, you
guessed it, throws the same IOException again.
My solution was to finally remove the finalizer for the FileStream object at
that point but this is very ugly. is there a way to Close the FileStream in
that situation?
Thanks,
Joël