2010-11-23 7 views
0

Quelqu'un s'il vous plaît donner un exemple, j'ai googlé mais n'a pas trouvé de résultat approprié.qu'est-ce que ICSharpCode.SharpZipLib.ZipEntry.Flag?

Je veux donner le drapeau afin qu'il compresser le fichier avec son nom d'origine en cas de nom de fichier

par exemple characters.for spéciale actuellement j'utilise

ZipEntry entry = new ZipEntry(file.FullName.Substring(directory.FullName.Length + 1)); 
        entry.Flags |= 2048; // enable UTF8 file names 

ce qui devrait être le drapeau pour soutenir le nom de fichier spécial charaters ??

Thanx

Répondre

3

code source pour ce composant est disponible ici:

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

Si vous téléchargez la source et examinez le code de ZipEntry, vous trouverez les commentaires suivants pour la propriété Flags .

/// 
/// 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> 

Donc, OU 2048 dans les drapeaux que vous avez fait semble correct. Ou, vous pouvez définir la propriété IsUnicodeText qui fait la même chose, bien que le code paraisse un peu plus propre:

entry.IsUnicodeText = true;