DotNetZip未压缩的exe文件无法打开

时间:2015-07-16 11:52:06

标签: c# .net exe dotnetzip

我一直在使用DotNetZip库解压缩ZIP文件中的某些文件,使用相同的库进行压缩。该ZIP文件包含exe文件,但一旦解压缩,一些解压缩的exe文件不再打开。如果我使用WinRAR手动解压缩文件,则不会发生这个问题。

我使用的代码就是这个...

if (!System.IO.File.Exists("ApplicationSample.zip")) { MessageBox.Show("No data found", "Warning"); return false; }
            var Archive = ZipFile.Open(DatFilePath, ZipArchiveMode.Read);
            var InstallPath = Environment.GetFolderPath(Environment.SpecialFolder.ProgramFiles) + @"/ApplicationSample";
            if (Directory.Exists(InstallPath))
            Directory.Delete(InstallPath, true);
            Directory.CreateDirectory(InstallPath);
            Archive.ExtractToDirectory(InstallPath);
            var ArchiveEd = new Ionic.Zip.ZipFile("ApplicationSample.zip");
            ArchiveEd.UseUnicodeAsNecessary = true;
            ArchiveEd.ZipError += ApplicationSample_ZipError;
            ArchiveEd.ExtractAll(InstallPath);
            ArchiveEd.Dispose();
            ShellLink link = new ShellLink();
            link.WorkingDirectory = InstallPath;
            link.Target = InstallPath + "/ApplicationSample.exe";
            link.IconPath = InstallPath + "/ApplicationSample.ico";
            link.Save(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) + "/ApplicationSample.lnk");

我试图打开的exe文件是一个WPF应用程序,如果我手动执行相同的操作,它可以正常工作。

我不知道这里发生了什么,我想知道问题是什么。

谢谢!

0 个答案:

没有答案