GZipStream give error Arithmetic operation resulted in an overflow.(more then 3 GB file)

  • Thread starter Thread starter harshad
  • Start date Start date
H

harshad

Dear All,

I use System.IO.Compression namespace for compressing file
give me overflow for streamObj.Length when file size more then 3 GB.

following my code:


Dim streamObj As Stream = File.OpenRead(GZipFileName)
Dim buffer(streamObj.Length) As Byte

streamObj.Read(buffer, 0, buffer.Length)
streamObj.Close()

Dim compFile As System.IO.FileStream =
File.Create((Path.ChangeExtension(GZipFileName, "GZip")))
Dim zipStreamObj As New GZipStream(compFile,
CompressionMode.Compress)

zipStreamObj.Write(buffer, 0, buffer.Length)
zipStreamObj.Close()


Thanks,

Harshad
 
Try reading the file in chunks instead of all at once.

--
HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP
 
Back
Top