Создать самоопространение архивов SFX

Aspose.zip позволяет создавать самопроизвольный (SFX) архив. Это особый вид Zipple File, который имеет расширение имени файла. Exe. Вы можете расстегнуть разаршивание файла самоизмещения, дважды щелкнув его.

Создание самопроизвольное архив

Создать самостоятельный архивный экземпляр SelfExtractorOptions и передайте его ArchivesaveOptions при сохранении.

1try (fileOutputStream ZipFile = new FileOutputStream ("archive.exe")) {
2    Попробуйте (Archive Archive = new Archive ()) {
3        archive.createEntry ("entry.bin", "data.bin");
4        ArchivesaveOptions Options = new ArchivesaveOptions ();
5        Options.SetShipxTractorOptions (New SelfExtractorOptions ());
6        archive.save (zipfile, опции);
7    }
8} catch (ioException ex) {
9}

Запуск самопроизвольного архива

Архив, который вы производите, является исполняемым и требует .NET Framework 2.0 или выше для запуска. Такие рамки снабжены Windows Vista и выше. Вы можете выполнить его как обычную программу с помощью двойного щелчка или запустить ее через интерфейс командной строки. Если вы хотите начать извлечение автоматически, укажите опцию командной строки -AutoExtract. Образец:

1C:\>archive.exe -autoExtract -password:T0p$ecret

Параметры командной строки для самоопространения архива

OptionMeaningSample
-autoExtract

Primary option - without it decompression does not start.

Extraction starts automatically, other options apply.

sfx.exe -autoExtract
-autoCloseWindow closes when the extraction is complete. This option only makes sense if -autoExtract option is present.sfx.exe -autoExtract -autoClose
-forceOverwriteOverwrites all existing files without prompt if there are any. This option only makes sense if -autoExtract option present.sfx.exe -autoExtract -forceOverwrite
-password:

Provides a password to encrypted entries. This option only makes sense if -autoExtract option is present.

If you have spaces within the password quote it.

sfx.exe -autoExtract -password:T0p$ecret
-destination:

Extracts files to the supplied directory. This option only makes sense if -autoExtract option is present.

If you have spaces within the path quote it.

sfx.exe -autoExtract -destination:"C:\My Documents"

Вы можете использовать эти параметры для сочинения пакетного скрипта в Windows.

Subscribe to Aspose Product Updates

Get monthly newsletters & offers directly delivered to your mailbox.