File and FileStreams

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

File and FileStreams

Jerome Chan
When i get a FileStream from a File object and I close the File object,
I sort of expected the FileStream object to be closed too. However, I
encountered an error from the Finalizer thread which indicates that its
trying to close an already closed file handle.

Would it be a better idea to automatically close FileStreams when the
File handles they are based on are closed?


Reply | Threaded
Open this post in threaded view
|

Re: File and FileStreams

Bill Schwab-2
Jerome,

> When i get a FileStream from a File object and I close the File object,
> I sort of expected the FileStream object to be closed too. However, I
> encountered an error from the Finalizer thread which indicates that its
> trying to close an already closed file handle.
>
> Would it be a better idea to automatically close FileStreams when the
> File handles they are based on are closed?

How/when to close files has been discussed at various times in the past, and
you can no doubt find more than you want to know<g> in Ian's archives.  What
I do (and it works well most of the time) is close the file stream in an
#ensure: block, but then I usually open files using FileStream class
methods.

Does that help?

Bill

--
Wilhelm K. Schwab, Ph.D.
[hidden email]