// открывает поток, не файл!!!
using (ZipArchive archive = ZipFile.OpenRead(zipPath))
{
// перебирает заголовки. Не файлы
foreach (ZipArchiveEntry entry in archive.Entries)
{
// понимаем что это наш клиент, условие может быть любое
if (entry.FullName.EndsWith(".txt", StringComparison.OrdinalIgnoreCase))
{
// Gets the full path to ensure that relative segments are removed.
string destinationPath = Path.GetFullPath(Path.Combine(extractPath, entry.FullName));
// Ordinal match is safest, case-sensitive volumes can be mounted within volumes that
// are case-insensitive.
if (destinationPath.StartsWith(extractPath, StringComparison.Ordinal))
entry.ExtractToFile(destinationPath); // только тут начинаем извлекать, причем память используется минимально это поток
}
}
}
const int width = 400;
const int height = 300;
var image = new uint[width * height * 3];
for (var i = 0; i < image.Length; i++) image[i] = 0xff;