IlSanto
IlSanto

Reputation: 83

How to create self-extracting archive in WPF C# with the DotNetZip library

I need to create an archive where I also encrypt the information on the files. So I tried to create a self-extracting archive by installing the DotNetZip package and wrote the sample code

using System.Windows;
using System.Windows.Shapes;
using System.IO;
using System.Text;
using System.Collections.Generic;
using Ionic.Zip;


 string DirectoryPath = folder;
 using (ZipFile zip = new ZipFile())
 {
     zip.AddDirectory(DirectoryPath, System.IO.Path.GetFileName(DirectoryPath));
          zip.Comment = "This will be embedded into a self-extracting WinForms-based exe";
          var options = new SelfExtractorOptions
         {
              Flavor = SelfExtractorFlavor.WinFormsApplication,
            DefaultExtractDirectory = "%USERPROFILE%\\ExtractHere",
            PostExtractCommandLine = ExeToRunAfterExtract,
            SfxExeWindowTitle = "My Custom Window Title",
            RemoveUnpackedFilesAfterExecute = true
          };
          zip.SaveSelfExtractor("archive.exe", options);
 }

but these names are not found in the wpf c# project

SelfExtractorOptions 
SelfExtractorFlavor
ExeToRunAfterExtract
SaveSelfExtractor

what should I add or change?

Upvotes: 0

Views: 97

Answers (0)

Related Questions