首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >什么是ICSharpCode.SharpZipLib.ZipEntry.Flag?

什么是ICSharpCode.SharpZipLib.ZipEntry.Flag?
EN

Stack Overflow用户
提问于 2010-11-23 22:56:13
回答 1查看 2.1K关注 0票数 0

有没有人能举个例子,我用谷歌搜索了一下,但没有找到合适的结果。

我想给出一个标志,这样在文件名的情况下,它就会用它的原始名称压缩文件

对于特殊的characters.for示例,我目前正在使用

代码语言:javascript
复制
ZipEntry entry = new ZipEntry(file.FullName.Substring(directory.FullName.Length + 1));
                    entry.Flags |= 2048; // enable UTF8 file names

支持特殊字符文件名的标志应该是什么?

谢谢

EN

回答 1

Stack Overflow用户

发布于 2010-11-23 23:48:38

此处提供了此组件的源代码:

http://www.icsharpcode.net/opensource/sharpziplib/Download.aspx

如果您下载源代码并查看ZipEntry的代码,您将发现Flags属性的以下注释。

代码语言:javascript
复制
///
/// Get/Set general purpose bit flag for entry
///
///
/// General purpose bit flag
///
/// Bit 0: If set, indicates the file is encrypted
/// Bit 1-2 Only used for compression type 6 Imploding, and 8, 9 deflating
/// Imploding:
/// Bit 1 if set indicates an 8K sliding dictionary was used.  If clear a 4k dictionary was used
/// Bit 2 if set indicates 3 Shannon-Fanno trees were used to encode the sliding dictionary, 2 otherwise
///
/// Deflating:
///   Bit 2    Bit 1
///     0        0       Normal compression was used
///     0        1       Maximum compression was used
///     1        0       Fast compression was used
///     1        1       Super fast compression was used
///
/// Bit 3: If set, the fields crc-32, compressed size
/// and uncompressed size are were not able to be written during zip file creation
/// The correct values are held in a data descriptor immediately following the compressed data.
/// Bit 4: Reserved for use by PKZIP for enhanced deflating
/// Bit 5: If set indicates the file contains compressed patch data
/// Bit 6: If set indicates strong encryption was used.
/// Bit 7-10: Unused or reserved
/// Bit 11: If set the name and comments for this entry are in <a href="http://www.unicode.org">unicode</a>.
/// Bit 12-15: Unused or reserved
///
/// <seealso cref="IsUnicodeText"></seealso>
/// <seealso cref="IsCrypted"></seealso>

因此,您所做的ORing 2048 into Flags看起来是正确的。或者,您可以设置IsUnicodeText属性,该属性做同样的事情,但会使代码看起来更干净一些:

代码语言:javascript
复制
entry.IsUnicodeText = true;
票数 3
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/4257298

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档