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

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
 
K

Kevin Spencer

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

--
HTH,

Kevin Spencer
Chicken Salad Surgeon
Microsoft MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top