简体   繁体   中英

Ionic.Zip throwing unexpected and weird error

I want to implement the Ionic.Zip.dll library in my project. I managed to make it work, but when I give him options to generate an archive, it suddenly throws the following error:

Ionic.Zip.SfxGenerationException was unhandled
Message=Errors compiling the extraction logic!

Does anyone know why this happens? Here is my code snipet which I belive is the cause, but apparently i cannot find any mistake.

TextWriter tw = new StreamWriter(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\temp.vbs");

// write a line of text to the file
tw.WriteLine(text);

// close the stream
tw.Close();
ZipFile zip = new ZipFile();
zip.AddFile(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) + "\\temp.vbs", "");
zip.Comment = "blabla";
SelfExtractorSaveOptions options = new SelfExtractorSaveOptions();
if (textBox1.Text != "") zip.Comment = zip.Comment + "\n\n" + "blabla: " + textBox1.Text;
if (textBox2.Text != "") zip.Comment = zip.Comment + "\nblabla: " + textBox2.Text;
if (textBox3.Text != "") options.IconFile = textBox3.Text;
options.Flavor = SelfExtractorFlavor.ConsoleApplication;
options.Quiet = true;
options.DefaultExtractDirectory = "%APPDATA%\\SomeFolder";
options.PostExtractCommandLine = "temp.vbs";
options.RemoveUnpackedFilesAfterExecute = true;
zip.SaveSelfExtractor(textBox4.Text, options);
System.Diagnostics.Process.Start(textBox4.Text);
this.Close();

Thank you in anticipation for your help!

PS Ionic.Zip can be found here: http://dotnetzip.codeplex.com/

I was getting this error, And getting a weird .cs file generated at the location I was expecting the .exe file (Also path to this file is added in the exception). I opened this file (DotNetZip-2018May30-150547-7b57e3d0-9c8e-402a-9da8-bda23ee8100c.cs) with a text editor and right at the end was a error.

For me it was a permission issue, Make sure that it can create the exe file.

Mine was working creating a zip but not a exe

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM