Streams supplied to constructors

16 views
Skip to first unread message

Oliver Bock

unread,
Jun 11, 2018, 11:07:16 PM6/11/18
to CSVChat
Does Close()/Dispose() close the stream supplied to XlsxReader(Stream)?  If not, when is it safe to close this stream?  From peering in using ILSpy it looks like it takes a copy of the entire document in memory, and it can be closed immediately.  However I don't think this applies to XlsReader.  Is there a general rule?

Regards,
  Oliver

shriop

unread,
Jun 12, 2018, 7:40:29 AM6/12/18
to CSVChat
Calling Close/Dispose on XlsxReader does not close the stream supplied in the constructor. The same goes for XlsReader.

Both XlsReader and XlsxReader use up the stream in the constructors and do not save a reference to the streams beyond the constructor's scope, so it would be safe to close the stream after calling the constructor.

Bruce Dunwiddie
Reply all
Reply to author
Forward
0 new messages