#nullable enable using System.Collections.Generic; using System.IO; using System.Linq; using System.Text; namespace MediaBrowser.Common.Extensions { /// /// Class BaseExtensions. /// public static class StreamExtensions { /// /// Reads all lines in the . /// /// The to read from. /// All lines in the stream. public static string[] ReadAllLines(this Stream stream) => ReadAllLines(stream, Encoding.UTF8); /// /// Reads all lines in the . /// /// The to read from. /// The character encoding to use. /// All lines in the stream. public static string[] ReadAllLines(this Stream stream, Encoding encoding) { using (StreamReader reader = new StreamReader(stream, encoding)) { return ReadAllLines(reader).ToArray(); } } /// /// Reads all lines in the . /// /// The to read from. /// All lines in the stream. public static IEnumerable ReadAllLines(this StreamReader reader) { string? line; while ((line = reader.ReadLine()) != null) { yield return line; } } } }