简体   繁体   English

Ionic.Zip抛出意外和奇怪的错误

[英]Ionic.Zip throwing unexpected and weird error

I want to implement the Ionic.Zip.dll library in my project. 我想在我的项目中实现Ionic.Zip.dll库。 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. 这是我的代码snipet,我相信是原因,但显然我找不到任何错误。

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/ PS Ionic.Zip可以在这里找到: 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). 我收到此错误,并获得一个奇怪的.cs文件生成在我期待的.exe文件的位置(此异常添加此文件的路径)。 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. 我用文本编辑器打开了这个文件(DotNetZip-2018May30-150547-7b57e3d0-9c8e-402a-9da8-bda23ee8100c.cs),最后是一个错误。

For me it was a permission issue, Make sure that it can create the exe file. 对我来说这是一个权限问题,请确保它可以创建exe文件。

Mine was working creating a zip but not a exe 我的工作正在创建一个拉链但不是exe

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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