Пример #1
0
        // http://stackoverflow.com/questions/1578823/creating-a-zip-extractor
        public static void CreateSelfExtra()
        {
            string DirectoryToZip  = "";
            string ZipFileToCreate = "";

            using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile())
            {
                zip.Comment = "This will be embedded into a self-extracting console-based exe";
                //zip.StatusMessageTextWriter = System.Console.Out;
                zip.AddDirectory(DirectoryToZip);                 // recurses subdirectories
                //zip.Password = "******";
                //zip.Encryption = Ionic.Zip.EncryptionAlgorithm.WinZipAes256;
                //zip.Save(ZipFileToCreate);


                Ionic.Zip.SelfExtractorSaveOptions options = new Ionic.Zip.SelfExtractorSaveOptions();
                options.Flavor = Ionic.Zip.SelfExtractorFlavor.ConsoleApplication;
                //options.DefaultExtractDirectory = System.IO.Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Desktop), System.IO.Directory.GetParent(ZipFileToCreate).Name);
                options.DefaultExtractDirectory = "%TEMP%";
                options.ExtractExistingFile     = Ionic.Zip.ExtractExistingFileAction.OverwriteSilently;

                // http://dotnetzip.codeplex.com/workitem/10682
                //options.IconFile = System.IO.Path.Combine(Application.StartupPath, "box_software.ico");
                //options.PostExtractCommandLine = "putty.exe";
                //options.Quiet = true;
                //options.RemoveUnpackedFilesAfterExecute = true;

                zip.SaveSelfExtractor(System.IO.Path.ChangeExtension(ZipFileToCreate, ".exe"), options);
            } // End Using zip
        }     // End Sub CreateSelfExtra
Пример #2
0
        }         // End Sub ZipWithDotNetZip

        public static void ZipAutoExtract()
        {
            using (Ionic.Zip.ZipFile zip = new Ionic.Zip.ZipFile())
            {
                // zip up a directory
                zip.AddDirectory("C:\\project1\\datafiles", "data");

                zip.Comment = "This will be embedded into a self-extracting exe";
                zip.AddEntry("Readme.txt", "This is content for a 'Readme' file that will appear in the zip.");
                zip.SaveSelfExtractor("archive.exe", Ionic.Zip.SelfExtractorFlavor.ConsoleApplication);
            }     // End Using zip
        }         // End Using ZipAutoExtract