It is quite easy to read the extract a file in a zip file but might be a bit alarming to just read the content of the file without extracting the file. Bellow is the code that just read the content of a file in a zip file without extracting the file.

using (var zipStream = new FileStream(“test.zip”, FileMode.Open))
using (var archive = new ZipArchive(zipStream, ZipArchiveMode.Read))
{
foreach (var entry in archive.Entries)
{
using (var stream = entry.Open())
using (var reader = new StreamReader(stream))
{
richTextBox1.AppendText(reader.ReadToEnd());
}
}
}

Then you will get your text in the rich text box on button click

If you have a question ask in the comment.

Advertisements