Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7060795
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T04:23:44+00:00 2026-05-28T04:23:44+00:00

Are there any zip components with such features? I need to download a zip

  • 0

Are there any zip components with such features? I need to download a zip archive from the Internet to a stream, then to open the archive from the stream and then to extract files to another stream.

E.g. ZipForge can open an archive from a stream ZipForge.OpenArchive(MyStream, false);
but how to extract to another one…?

procedure ExtractToStream(FileName: WideString; Stream: TStream); 

Description

Use ExtractToStream to decompress data stored in the file inside the
archive to a TStream descendant object like TFileStream, TMemoryStream
or TBlobStream.

The FileName parameter specifies file name being extracted.

And what use of the OpenArchive(MyStream, false) method if extraction isn’t supported…

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T04:23:44+00:00Added an answer on May 28, 2026 at 4:23 am

    The zip file component that is built into XE2 will do this.

    There is an overloaded Open method that receives a TStream as its input parameters.

    To extract individual files you can call an overloaded Read method passing the name of the file that you wish to extract. The extracted file is returned as a new instance of TStream. You can that use CopyFrom on that instance to transfer the extracted file to your stream.

    var
      ZipFile: TZipFile;
      DownloadedStream, DecompressionStream, MyStream: TStream;
      LocalHeader: TZipHeader;
    ...
    ZipFile := TZipFile.Create;
    try
      ZipFile.Open(DownloadedStream, zmRead);
      ZipFile.Read('myzippedfile', DecompressionStream, LocalHeader);
      try
        MyStream.CopyFrom(DecompressionStream, DecompressionStream.Size);
      finally
        DecompressionStream.Free;
      end;
    finally
      ZipFile.Free;
    end;
    

    Note that I’ve not tested this code, I’ve just written it based on the source code for TZipFile and the documentation contained in that source code. There may be a few wrinkles in this but if the code behaves as advertised it meets your needs perfectly.


    OK, now I tested it because I was curious. Here’s the program that shows that this all works as advertised:

    program ZipTest;
    
    {$APPTYPE CONSOLE}
    
    uses
      System.SysUtils,
      System.Classes,
      System.Zip;
    
    procedure ExtractToFile(
      const ZipFileName: string;
      const ZippedFileIndex: Integer;
      const ExtractedFileName: string
    );
    var
      ZipFile: TZipFile;
      DownloadedStream, DecompressionStream, OutputStream: TStream;
      LocalHeader: TZipHeader;
    begin
      DownloadedStream := TFileStream.Create(ZipFileName, fmOpenRead);
      try
        ZipFile := TZipFile.Create;
        try
          ZipFile.Open(DownloadedStream, zmRead);
          ZipFile.Read(ZippedFileIndex, DecompressionStream, LocalHeader);
          try
            OutputStream := TFileStream.Create(ExtractedFileName, fmCreate);
            try
              OutputStream.CopyFrom(DecompressionStream, DecompressionStream.Size);
            finally
              OutputStream.Free;
            end;
          finally
            DecompressionStream.Free;
          end;
        finally
          ZipFile.Free;
        end;
      finally
        DownloadedStream.Free;
      end;
    end;
    
    begin
      try
        ExtractToFile('C:\desktop\test.zip', 0, 'C:\desktop\out.txt');
      except
        on E: Exception do
          Writeln(E.ClassName, ': ', E.Message);
      end;
    end.
    

    Note that I extracted by index rather than file name since that was more convenient for me. And I used file streams rather than memory streams which I imagine you would use. However, since the TZipFile methods work with TStream I’m sure that the code will work with streams of any form.


    This is the latest in a series of questions about ZIP files. I know that you are using XE2 and I wonder why you seem reluctant to use the built in ZIP class that XE2 provides. I’ve not seen anything to indicate that it will not fulfil your requirements. In fact, it is precisely this ability to work directly with streams that makes me feel it has sufficient generality for any application.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a ZIP archive with many files, is there any way to export
Are there any open source tools for searching the contents of zipper files such
Is there any way of modifying a zip on android without having to extract
Is there any Ruby equivalent for Python's builtin zip function? If not, what is
Is there any way to capture the MouseDown even from the .NET 2.0 TextBox
Is there any google/Yahoo/Bing API which gives local business results based on a ZIP/GeoCode
Is there any software/script that will allow me to cd (change directories) into .jar/.ear/.zip
If your website has deflate/zip compression enabled is there any point to JavaScript minification?
I would like to ignore hidden files when extracting a zip. Is there any
Is there any way to return dictionary result from adbapi query to MySQL? [name:

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.