SaveSelfExtractor Method (exeToGenerate, options)

DotNetZip

Ionic Zip Library v1.9.1.6 SaveSelfExtractor Method (exeToGenerate, options)
ReferenceIonic.ZipZipFileSaveSelfExtractor(String, SelfExtractorSaveOptions)
Saves the ZipFile instance to a self-extracting zip archive, using the specified save options.
Declaration Syntax
C# Visual Basic Visual C++
public void SaveSelfExtractor(
	string exeToGenerate,
	SelfExtractorSaveOptions options
)
Public Sub SaveSelfExtractor ( _
	exeToGenerate As String, _
	options As SelfExtractorSaveOptions _
)
public:
void SaveSelfExtractor(
	String^ exeToGenerate, 
	SelfExtractorSaveOptions^ options
)
Parameters
exeToGenerate (String)
The name of the EXE to generate.
options (SelfExtractorSaveOptions)
provides the options for creating the Self-extracting archive.
Remarks

This method saves a self extracting archive, using the specified save options. These options include the flavor of the SFX, the default extract directory, the icon file, and so on. See the documentation for SaveSelfExtractor(String, SelfExtractorFlavor) for more details.

The user who runs the SFX will have the opportunity to change the extract directory before extracting. If at the time of extraction, the specified directory does not exist, the SFX will create the directory before extracting the files.

Examples
This example saves a WinForms-based self-extracting archive EXE that will use c:\ExtractHere as the default extract location. The C# code shows syntax for .NET 3.0, which uses an object initializer for the SelfExtractorOptions object.
CopyC#
string DirectoryPath = "c:\\Documents\\Project7";
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);
}
CopyVB.NET
Dim DirectoryPath As String = "c:\Documents\Project7"
Using zip As New ZipFile()
    zip.AddDirectory(DirectoryPath, System.IO.Path.GetFileName(DirectoryPath))
    zip.Comment = "This will be embedded into a self-extracting console-based exe"
    Dim options As New SelfExtractorOptions()
    options.Flavor = SelfExtractorFlavor.WinFormsApplication
    options.DefaultExtractDirectory = "%USERPROFILE%\\ExtractHere"
    options.PostExtractCommandLine = ExeToRunAfterExtract
    options.SfxExeWindowTitle = "My Custom Window Title"
    options.RemoveUnpackedFilesAfterExecute = True
    zip.SaveSelfExtractor("archive.exe", options)
End Using

Assembly: Ionic.Zip (Module: Ionic.Zip) Version: 1.9.1.8 (1.9.1.8)