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

标签 c# extract dotnetzip

我想在我的项目中实现 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/

相关文章:

c# - 在 CustomActions 类中设置项目窗口处理程序

java正则表达式从带有日期的较大字符串中排除特定权重

linux - 使用 power iso 提取 VMDK 文件

c# - DotNetZip 取消任务中的提取

c# - 从 dotnetzip 创建的 zip 文件中提取时出错 - "Windows cannot complete the extraction."

c# - DotNetZip 从 MemoryStream 打开 zip 文件

c# - 无法安装 Visual Studio Code C# 扩展

如果 C# Windows 服务包含(嵌入) Entity Framework ,则不会安装

c# - 使用 Linq 检查 C# 中的目录

Java:如何使用 jsoup 从新闻页面提取标题?