我想在我的项目中实现 Ionic.Zip.dll 库。我设法使它工作,但是当我给他生成存档的选项时,它突然抛出以下错误:
Ionic.Zip.SfxGenerationException was unhandled
Message=Errors compiling the extraction logic!
有人知道为什么会这样吗?这是我的代码片段,我认为这是原因,但显然我找不到任何错误。
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();
期待您的帮助!
附言Ionic.Zip 可以在这里找到:http://dotnetzip.codeplex.com/
最佳答案
我收到此错误,并在我期望 .exe 文件的位置生成了一个奇怪的 .cs 文件(异常中还添加了此文件的路径)。我用文本编辑器打开这个文件 (DotNetZip-2018May30-150547-7b57e3d0-9c8e-402a-9da8-bda23ee8100c.cs),最后是一个错误。
对我来说这是一个权限问题,确保它可以创建 exe 文件。
我的正在创建一个 zip 而不是一个 exe
关于c# - Ionic.Zip 抛出意外和奇怪的错误,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14446446/