My question has already kind of been asked at Releasing underlying Stream returned by Application.GetResourceStream on WP7, but I have a couple variations on the question:
- This is for a desktop WPF application, not WP7 if it makes any difference.
- I have to decide whether to use a
using
block on a stream reader built on top of the stream.
Here's some code:
System.Windows.Resources.StreamResourceInfo ri =
App.GetResourceStream(new Uri("Resources/Idioms.txt", UriKind.Relative));
using (System.IO.StreamReader sr = new System.IO.StreamReader(ri.Stream))
{
idioms = sr.ReadToEnd().Split(lineSeps, StringSplitOptions.RemoveEmptyEntries);
}
Now StreamReader's close method (which I assume is the method that implements IDisposable.Dispose
) indicates that it also closes the underlying stream (which I assume is also implementing IDisposable.Dispose
).
So is this closing or disposing of the IO.Stream
object provided by GetResourceStream
's Stream
property:
- Expected
- Acceptable, or
- Incorrect
(Should I use or avoid using
on the reader built on top of the stream?)