This project is read-only.

Progress Reporting | Background Worker | Using using | How To

Jan 13, 2013 at 3:48 AM
Edited Jan 13, 2013 at 4:01 AM


I have spent several days trying to get this obviously excellent library working to conventions that I understand. The documentation is non-existent and this forum is obviously only visited when we have a problem getting it to work. Clearly this library took quite some time to write and just must work - hence my persistence. After much reading of comments in this forum, I came across the solution only with educated guesses. I share the results herewith.

First of all - get an updated port of this library at this github address. Compile that library and add a reference in your project to the Windows assembly. The reference adding will fix all the compile time errors - it did for me targeting .Net 4.

The following code is the guts of my Forms project. I've edited the real one quite a bit as it contains heaps for test code and trial/error coding.

setup() is called in my form initialization method. bwinstallupdates is my backgroundworker

    public string SevenZipDLLPath { get; set; }

    private void setup()
      if (Environment.Is64BitOperatingSystem)
        SevenZipDLLPath = Path.Combine(Application.StartupPath, "bin", "7zx64.dll");
        SevenZipDLLPath = Path.Combine(Application.StartupPath, "bin", "7zx32.dll");

    private void button1_Click(object sender, EventArgs e)
    void extr_ExtractionFinished(object sender, EventArgs e)
      sevenzipFinished = true;

    void extr_FileExists(object sender, FileOverwriteEventArgs e)


    void extr_FileExtractionStarted(object sender, FileInfoEventArgs e)


    void extr_Extracting(object sender, ProgressEventArgs e)
    private bool installMC(string archiveName)
      string targetDirectory = Path.Combine(tempDirectory, @"Webserver\htdocs");
      string workingDirectory = Path.Combine(tempDirectory, "Work");
      string newVersionFile = Path.Combine(Application.StartupPath, archiveName);
      string tempBackupDirectory = Path.Combine(tempDirectory, "TempBackup");
      string tempBackupFile = Path.Combine(tempBackupDirectory, "");

      bool success = true;

      if (File.Exists(newVersionFile))
        if (Directory.Exists(workingDirectory))
          Directory.Delete(workingDirectory, true);


        currentlyInstallingText = "Extracting archive:";
        string fileName = @"C:\Trash\";
        string directory = workingDirectory;

        sevenzipFinished = false;

        using (SevenZipExtractor extr = new SevenZipExtractor(newVersionFile, "password"))
          extr.Extracting += new EventHandler<ProgressEventArgs>(extr_Extracting);
          extr.FileExtractionStarted += new EventHandler<FileInfoEventArgs>(extr_FileExtractionStarted);
          extr.FileExists += new EventHandler<FileOverwriteEventArgs>(extr_FileExists);
          extr.ExtractionFinished += new EventHandler<EventArgs>(extr_ExtractionFinished);
          extr.EventSynchronization = EventSynchronizationStrategy.AlwaysAsynchronous;
        return success;
    private void bwInstallUpdates_ProgressChanged(object sender, ProgressChangedEventArgs e)
      pbUpdating.Visible = true;
        private void bwInstallUpdates_DoWork(object sender, DoWorkEventArgs e)

    private void bwInstallUpdates_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)


I hope the above helps you.