Unzipping a stream containing a zip file

WinForms

ComponentOne's WinForms controls

Unzipping a stream containing a zip file

  • rated by 0 users
  • This post has 1 Reply |
  • 0 Followers
  • Hi,

    Apologies in advance in case I am missing the obvious, but despite reading the C1 help file, examples and previous forum posts, I'm not clear whether it is possible to 'unzip' a streamed zip file and save the file it contains without an intermediate stage of processing.

    The situation is that I regularly have to download a zipped file from a public internet site (containing one small excel .csv workbook).  I then need to unzip the file, extract some data from the workbook and update a series of database records using the new values.  I currently use the approach of downloading and saving the zip file, then use C1Zip to extract the data from the saved zip file eg: 

    zipFile.Open(savedfilepath)

    Dim zipStream As Stream = zipFile.Entries(0).OpenReader

    Dim myStreamReader As StreamReader = New StreamReader(zipStream)

    Dim zipText As String = myStreamReader.ReadToEnd()

    zipStream.Close()

    This works fine, but I am now very interested to find out whether I could unzip the stream 'on the fly' as it is received, to avoid having to save the zip file first (there are some other situations where I could use this approach with real benefits).  Having looked at all the information I mentioned earlier in the post I can't work out if the tools are available in C1 Zip to do this yet.  If so I'd be very grateful for any experience, pointers or example code anyone could provide to help me.

    Thanks in advance, and regards,

    Rod

     

     

     

  • As of version #20071.40 (Feb 2007) C1Zip can open file streams and not just file paths.

    C1ZipFile.Open(Stream)

    I'm not sure if this will work in your situation, but I noticed most of the forum talk is dated before this release when this was not possible.

    Regards,
    Greg

    Greg Lutz ComponentOne

Page 1 of 1 (2 items)