Я хочу разархивировать файл и извлечь содержимое из заархивированного файла, который присутствует в хранилище BLOB-объектов Azure.
Я использую пакет SharpZipLib для достижения этой цели.Я сталкиваюсь с несколькими ошибками, последней из которых является «Положение InflaterInputStream не поддерживается».Я что-то упустил?
public static string DeCompressZipAndGetContent(Stream zipStream)
{
var content = string.Empty;
zipStream.Position = 0;
ZipInputStream zipInputStream = new ZipInputStream(zipStream);
ZipEntry zipEntry = zipInputStream.GetNextEntry();
while (zipEntry != null)
{
String entryFileName = zipEntry.Name;
byte[] buffer = new byte[4096];
using (Stream outStream = new MemoryStream())
{
CopyFromOneStreamToAnother(zipInputStream, outStream, buffer);
outStream.Position = 0;
using (StreamReader reader = new StreamReader(outStream, Encoding.UTF8))
{
content = reader.ReadToEnd();
}
}
}
return content;
}
private static void CopyFromOneStreamToAnother(Stream source, Stream destination, byte[] buffer)
{
bool copying = true;
while (copying)
{
int bytesRead = source.Read(buffer, 0, buffer.Length);
if (bytesRead > 0)
destination.Write(buffer, 0, bytesRead);
else
{
destination.Flush();
copying = false;
}
}
}