邮编条目名称在目录分隔符结束,但包含数据 [英] Zip entry name ends in directory separator character but contains data

查看:278
本文介绍了邮编条目名称在目录分隔符结束,但包含数据的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

  System.IO.Compression.ZipFile.ExtractToDirectory(zipPath,extractPath); 

在C#中使用ZipFile中,我试图从已知位置提取一个文件,它是扔以下错误:
System.IO.Exception:ZIP条目名称在目录分隔符,结尾却蕴含



我做了一些研究,ExtractToDirectory解释数据在MSDN中却找不到这个错误的定义。 ?你能解释为什么这个错误发生



从MSDN:



IOException异常。




由destinationDirectoryName指定的目录已经存在




- 或 -



在归档中的条目的名称是空的,仅包含空白,或至少包含一个无效字符



- 或 -




提取存档条目将创建一个文件,该文件是destinationDirectoryName指定的目录之外。 (例如,如果输入的名称中包含父目录访问,这可能发生。)




- 或 -




这是存档进入提取物具有相同的名称已经从同一个归档文件中提取的条目。



解决方案

我的研究表明,当你使用超压缩级别压缩为7-Zip实用程序中的文件,某些档案不能与.NET系统解压.IO.Compression.ZipFile.ExtractToDirectory()方法。
中的错误消息:ZIP条目名称在目录分隔符结束,但包含数据



根据我的观察,出现此错误只有当以下三个条件满足:




  1. 目标归档大 - 500MB +(小档案似乎解压罚款)

  2. <。 LI>归档文件的根目录仅包含文件夹(如果你添加至少一个文件存档,也解压细的根目录)。
  3. 7-Zip的超压使用。






在最后,我发现了三个解决方案,这7-Zip的错误。



解决方案1 ​​:添加至少一个文件到文件的根目录(任何假文件或readme.txt文件)



解决方案2 :使用本机Windows压缩实用程序(选择文件,单击鼠标右键,发送到 - >压缩文件夹中)


$。 b $ b

解决方案3 :不要使用7-Zip的超压缩



所有这些解决方案解决了我的问题。选择适合你的最好的项目之一。


System.IO.Compression.ZipFile.ExtractToDirectory(zipPath, extractPath);

Using ZipFile in C#, I'm trying to extract a file from a known location and it is throwing the following error: System.IO.Exception: Zip entry name ends in directory separator character but contains data

I've done some research, ExtractToDirectory is explained in MSDN but couldn't find this error definition. Would you be able to explain why this error is happening?

From MSDN:

IOException

The directory specified by destinationDirectoryName already exists.

-or-

The name of an entry in the archive is Empty, contains only white space, or contains at least one invalid character.

-or-

Extracting an archive entry would create a file that is outside the directory specified by destinationDirectoryName. (For example, this might happen if the entry name contains parent directory accessors.)

-or-

An archive entry to extract has the same name as an entry that has already been extracted from the same archive.

解决方案

My research shows that when you compress the files with 7-Zip utility using "Ultra" compression level, certain archives cannot be unzipped with .NET System.IO.Compression.ZipFile.ExtractToDirectory() method. The error message is: Zip entry name ends in directory separator character but contains data.

Based on my observation, this error occurs only if the following 3 conditions are met:

  1. The target archive is large - 500MB+ (Small archives seem to unzip fine).
  2. The root of the archive contains ONLY FOLDERS (if you add at least one file to the root of the archive it also unzips fine).
  3. 7-Zip Ultra compression is used.


In the end I found three solutions to this 7-Zip bug.

Solution 1: Add at least one file to the root of the archive (any dummy file or a readme.txt file).

Solution 2: Use native Windows compression utility (Select files, right-click, Send To -> Compressed folder).

Solution 3: Do not use 7-Zip Ultra compression.

All of these solutions resolved the problem for me. Pick the one that fits your project best.

这篇关于邮编条目名称在目录分隔符结束,但包含数据的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆