I have a simple text file setup as a Resource through my application's Properties as a byte[]. In order to access a "Stream.ReadLine" function, I believe I need to make it into a StreamReader. Is there a way to get the following result using only 1 Stream, or else, any tricks to make it better?
List<string> list = new List<string>();
using (Stream s = new MemoryStream(myFile))
{
using (StreamReader sr = new StreamReader(s))
{
while (!sr.EndOfStream)
{
list.Add(sr.ReadLine());
}
}
}
StreamReader
is for reading text,MemoryStream
is for raw, formatless data, where 'reading a line' has no meaning. \$\endgroup\$