Sto tentando di decomprimere un file (.gz) utilizzando la classe GZipStream inclusa nel framework .NET. Sto usando la documentazione MSDN e continuo a ricevere questa eccezione: "La scrittura sul flusso di compressione non è supportata."La scrittura nel flusso di compressione non è supportata. Utilizzo di System.IO.GZipStream
Ecco la sorgente dell'applicazione:
try
{
var infile = new FileStream(@"C:\TarDecomp\TarDecomp\TarDecomp\bin\Debug\nick_blah-2008.tar.gz", FileMode.Open, FileAccess.Read, FileShare.Read);
byte[] buffer = new byte[infile.Length];
// Read the file to ensure it is readable.
int count = infile.Read(buffer, 0, buffer.Length);
if (count != buffer.Length)
{
infile.Close();
Console.WriteLine("Test Failed: Unable to read data from file");
return;
}
infile.Close();
MemoryStream ms = new MemoryStream();
// Use the newly created memory stream for the compressed data.
GZipStream compressedzipStream = new GZipStream(ms, CompressionMode.Decompress, true);
Console.WriteLine("Decompression");
compressedzipStream.Write(buffer, 0, buffer.Length);
// Close the stream.
compressedzipStream.Close();
Console.WriteLine("Original size: {0}, Compressed size: {1}", buffer.Length, ms.Length);
L'eccezione viene generata al compressedZipStream.write().
Qualche idea? Cosa mi sta dicendo questa eccezione? Grazie!
Sto provando questo grazie. – Nick
Il tuo uomo .. Grazie! – Nick
Felice di aiutare. :) –