The first code will get you an Array of String, as if it were "ReadAllLines". The second one will get you a single String (as if it were "ReadAllText").
List<string> lines = new List<string>();
using (ZipArchive archive = ZipFile.OpenRead(zipPath))
{
foreach (ZipArchiveEntry entry in archive.Entries.Where(e_ => e_.Name == "example.txt"))
{
Stream stream = entry.Open();
using (var sr = new StreamReader(stream, Encoding.UTF8))
{
string line;
while ((line = sr.ReadLine()) != null)
{
lines.Add(line);
}
}
}
}
string[] result = lines.ToArray();
string result = "";
using (ZipArchive archive = ZipFile.OpenRead(zipPath))
{
foreach (ZipArchiveEntry entry in archive.Entries.Where(e_ => e_.Name == "example.txt"))
{
Stream stream = entry.Open();
using (var sr = new StreamReader(stream, Encoding.UTF8))
{
result = sr.ReadToEnd();
}
}
}