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 430531
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T19:53:05+00:00 2026-05-12T19:53:05+00:00

I want to create a zip extractor for plugins that I create for asp.net

  • 0

I want to create a zip extractor for plugins that I create for asp.net sites. I want the client to be able to run the extractor and the files are placed into the correct folders that I specify. Are there any tools for this? I’m not sure how to do this, thanks

  • 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-12T19:53:05+00:00Added an answer on May 12, 2026 at 7:53 pm

    DotNetZip is a library that allows managed code apps to read or write zip files. One thing it allows you to do is produce a self-extracting archive (SFX).

    In C#, the code to produce an SFX archive with DotNetZip looks like this:

    using (ZipFile zip1 = new ZipFile())
    {
        // zip up a directory
        zip1.AddDirectory("C:\\project1\\datafiles", "data");
        zip1.Comment = "This will be embedded into a self-extracting exe";
        zip1.AddEntry("Readme.txt", "This is content for a 'Readme' file that will appear in the zip.");
        zip1.SaveSelfExtractor("archive.exe", SelfExtractorFlavor.WinFormsApplication);
    }
    

    You choose how to shape the folder hierarchy in the ZIP file. The only rule is, upon extracting, the extraction happens to a particular root or parent folder. (You cannot extract to 7 different directories scattered about the filesystem)

    The resulting EXE requires the .NET Framework 2.0 or later in order to run, but nothing else.

    The SFX/EXE is also a regular Zip file that you can read and extract with WinZip, or other zip tools, including Windows Explorer “Compressed Folders”.

    The SFX composes with the other zip features, including

    • WinZip AES encryption – so you can encrypt the thing and only allow unpacking for someone who knows the password.
    • ZIP64 for very large archives.
    • Unicode, for filenames outside of the normal ~ASCII range.
    • restoration of File attributes, timestamps, etc.

    In DotNetZip, there are two possible flavors of SFX that you can generate: a console app or a WinForms app. The WinForms UI is generated for you – nothing to write or design. It’s simple and utilitarian, and looks like this:

    alt text

    The console flavor is more suited to being used in a script, or in a headless (no UI) scenario.


    There are a bunch of options when producing the SFX, like:

    • whether to open Explorer after unpacking
    • a command to execute after unpack (the command can be part of what was unpacked)
    • optionally remove all files after the ‘execute on unpack’ command completes successfully. Nice for a patch utility.
    • whether to overwrite existing files
    • the Win32 icon to use for the SFX EXE, or just accept the default
    • a default extract directory, which can be based on the user’s environment, eg %USERPROFILE%.
    • “quiet” mode, which means when it runs, it offers either no UI at all if you are using a console app, or only a simple progress bar if using the WinForms flavor. There are no buttons to click – this SFX just unpacks automatically.

    All these options for how the SFX will behave is accessible via the DotNetZip class library interface.


    If you don’t like the UI or the working model for the built-in SFX capability, there’s an easy way to provide your own self-extractor UI + logic. For example you could build an app in WPF and make it all snazzy and visually dyanmic. The way it works is pretty simple: in the code that produces the SFX, copy your unzip stub EXE (WinForms, WPF, or whatever) to an output stream, and then, without closing the stream, save the Zip file to the same stream. It looks like this in VB:

    Public Shared Function Main(ByVal args As String()) As Integer
        Dim sfxStub As String = "my-sfx-stub.exe"
        Dim outputFile As String = "my-sfx-archive.exe"
        Dim directoryToZip As String = "c:\directory\to\ZIP"
        Dim buffer As Byte() = New Byte(4000){}
        Dim n As Integer = 1
        Using output As System.IO.Stream = File.Open(outputFile, FileMode.Create)
            '' copy the contents of the sfx stub to the output stream
            Using input As System.IO.Stream = File.Open(sfxStub, FileMode.Open)
                While n <> 0
                    n = input.Read(buffer, 0, buffer.Length)
                    If n <> 0 Then
                        output.Write(buffer, 0, n)
                    End If
                End While
            End Using
            '' now save the zip file to the same stream
            Using zp As New ZipFile
                zp.AddFiles(Directory.GetFiles(directoryToZip), False, "")
                zp.Save(output)
            End Using
        End Using
    End Function
    

    The resulting file created by this code is both an EXE and a ZIP file. The stub EXE must read from itself in order to extract. In the example from above, the code for the my-sfx-stub.exe program could be something as simple as this:

    Dim a As Assembly = Assembly.GetExecutingAssembly
    Try
        '' read myself as a zip file
        Using zip As ZipFile = ZipFile.Read(a.Location)
            Dim entry As ZipEntry
            For Each entry in zip
                '' extract here, or add to a listBox, etc. 
                '' listBox1.Items.Add(entry.FileName)
            Next
        End Using
    Catch
        MessageBox.Show("-No embedded zip file.-")
    End Try
    

    A custom SFX constructed in this simple way will have a dependency on the DotNetZip DLL. To avoid this, and to produce a single self-contained EXE that can extract with no additional DLL dependencies, you can use ILMerge, or, embed the DotNetZip DLL as a resource and use an AssemblyResolver event to load it from the embedded resources.

    If you have questions, you can ask on the DotNetZip forums.

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

Sidebar

Related Questions

I want to create a client side mail creator web page. I know the
I want to create a function that performs a function passed by parameter on
I want to create a simple http proxy server that does some very basic
I want create a drop shadow around the canvas component in flex. Technically speaking
I want to create a Java application bundle for Mac without using Mac. According
I want to create a draggable and resizable window in JavaScript for cross browser
I want to create an allocator which provides memory with the following attributes: cannot
I want to create my Rails application with MySQL, because I like it so
I want to create a number of masked edit extenders from codebehind. Something like:
I want to create dynamic content based on this. I know it's somewhere, as

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.