Tag: system.io.compression

打开使用System.IO.Compression创建的ZipArchive时出现C#.NET缺失方法exception

我有一个C#WinForms .NET应用程序,我正在尝试写入zip存档并使用System.IO.Compression从中读取。 现在我创建了ziparchive: public void SaveStdV20ZipProject(string strfilepath, clsProjectInfo GameInfo) { using (var ms = new MemoryStream()) { using (var archive = new ZipArchive(ms, ZipArchiveMode.Create, true)) { string strProjectData = String.Empty; StringBuilder sb = new StringBuilder(); // First, we add the Game Info data… sb.AppendLine(GameInfo.strGameVersion); sb.AppendLine(GameInfo.strProjectType); sb.AppendLine(GameInfo.strGameTitle); sb.AppendLine(GameInfo.strAuthor); sb.AppendLine(GameInfo.strCreationDate); sb.AppendLine(GameInfo.blTSImagePresent.ToString()); sb.AppendLine(GameInfo.blTSAudioPresent.ToString()); sb.AppendLine(GameInfo.blTSVideoPresent.ToString()); sb.AppendLine(GameInfo.blFSSImagePresent.ToString()); sb.AppendLine(GameInfo.blFSSAudioPresent.ToString()); sb.AppendLine(GameInfo.blFSSVideoPresent.ToString()); sb.AppendLine(GameInfo.intTotalQuestions.ToString()); […]

ZipArchive给出意外的数据结束错误

我正在尝试使用一些字节数组数据动态创建一个zip流,并通过我的MVC动作下载。 但是在Windows中打开时,下载的文件总是会出现以下损坏的错误。 当我尝试从7z提取时出现此错误 但请注意,从7z中提取的文件未损坏。 我正在使用ZipArchive ,下面是我的代码。 private byte[] GetZippedPods(IEnumerable pods, long consignmentID) { using (var zipStream = new MemoryStream()) { //Create an archive and store the stream in memory. using (var zipArchive = new ZipArchive(zipStream, ZipArchiveMode.Create, true)) { int index = 1; foreach (var pod in pods) { var zipEntry = zipArchive.CreateEntry($”POD{consignmentID}{index++}.png”, CompressionLevel.NoCompression); using (var […]