GZipStream compress problem in windows 2008 server R2

Posted on 2012-09-10
Last Modified: 2013-05-15

I am using GZipStream to compress a database file that has been taken backup from Sql server 2008

Compression has been working fine other than windows server 2008 R2 environment.

I have attached the error message also.

Please help me solve this issue..

Thanks in advance..

The code am using to compress is,

Private Sub Compress(ByVal sPath As String, ByVal ZPath As String)
        Dim srcFile As String = sPath
        Dim dstFile As String = ZPath

        Dim fsIn As FileStream = Nothing
        ' will open and read the srcFile
        Dim fsOut As FileStream = Nothing
        ' will be used by the GZipStream for output to the dstFile
        Dim gzip As GZipStream = Nothing
        Dim buffer As Byte()
        Dim count As Integer = 0

            fsOut = New FileStream(dstFile, FileMode.Create, FileAccess.Write, FileShare.None)
            gzip = New GZipStream(fsOut, CompressionMode.Compress, True)

            fsIn = New FileStream(srcFile, FileMode.Open, FileAccess.Read, FileShare.Read)
            buffer = New Byte(fsIn.Length - 1) {}
            count = fsIn.Read(buffer, 0, buffer.Length)
            fsIn = Nothing

            ' compress to the destination file
            gzip.Write(buffer, 0, buffer.Length)
        Catch ex As Exception
            ' handle or display the error
            System.Diagnostics.Debug.Assert(False, ex.ToString())
            If gzip IsNot Nothing Then
                gzip = Nothing
            End If
            If fsOut IsNot Nothing Then
                fsOut = Nothing
            End If
            If fsIn IsNot Nothing Then
                fsIn = Nothing
            End If
        End Try

    End Sub
Question by:zillion_kamesh
    LVL 83

    Expert Comment

    Would you consider using a free 3rd party library?

    Author Comment


    I have found that the issue is happening based on the file size..

    When i compress a file with the file size of 203 MB its working fine..

    But the issue happens when am trying to compress a file that has the size of 2.55 GB.

    Also the error flashing in the execution of following code..

    buffer = New Byte(fsIn.Length - 1) {}

    Hope this will be helpful to solve..

    Note : I have to compress the file size of 20 GB to 50 GB.

    LVL 83

    Accepted Solution

    buffer = New Byte(fsIn.Length - 1) {}

    Hope this will be helpful to solve..

    Note : I have to compress the file size of 20 GB to 50 GB.

    Good luck with creating a 50GB buffer :-)

    Try with a 3rd party library or try using 7zip on command line.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    How to improve team productivity

    Quip adds documents, spreadsheets, and tasklists to your Slack experience
    - Elevate ideas to Quip docs
    - Share Quip docs in Slack
    - Get notified of changes to your docs
    - Available on iOS/Android/Desktop/Web
    - Online/Offline

    Scenario:  You do full backups to a internal hard drive in either product (SBS or Server 2008).  All goes well for a very long time.  One day, backups begin to fail with a message that the disk is full.  Your disk contains many, many more backups th…
    International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
    This tutorial will walk an individual through the steps necessary to enable the VMware\Hyper-V licensed feature of Backup Exec 2012. In addition, how to add a VMware server and configure a backup job. The first step is to acquire the necessary licen…
    Via a live example, show how to setup several different housekeeping processes for a SQL Server.

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    7 Experts available now in Live!

    Get 1:1 Help Now