IsText Property

DotNetZip

Ionic Zip Library v1.9.1.6 IsText Property
ReferenceIonic.ZipZipEntryIsText
Indicates whether an entry is marked as a text file. Be careful when using on this property. Unless you have a good reason, you should probably ignore this property.
Declaration Syntax
C# Visual Basic Visual C++
public bool IsText { get; set; }
Public Property IsText As Boolean
	Get
	Set
public:
property bool IsText {
	bool get ();
	void set (bool value);
}
Remarks

The ZIP format includes a provision for specifying whether an entry in the zip archive is a text or binary file. This property exposes that metadata item. Be careful when using this property: It's not clear that this property as a firm meaning, across tools and libraries.

To be clear, when reading a zip file, the property value may or may not be set, and its value may or may not be valid. Not all entries that you may think of as "text" entries will be so marked, and entries marked as "text" are not guaranteed in any way to be text entries. Whether the value is set and set correctly depends entirely on the application that produced the zip file.

There are many zip tools available, and when creating zip files, some of them "respect" the IsText metadata field, and some of them do not. Unfortunately, even when an application tries to do "the right thing", it's not always clear what "the right thing" is.

There's no firm definition of just what it means to be "a text file", and the zip specification does not help in this regard. Twenty years ago, text was ASCII, each byte was less than 127. IsText meant, all bytes in the file were less than 127. These days, it is not the case that all text files have all bytes less than 127. Any unicode file may have bytes that are above 0x7f. The zip specification has nothing to say on this topic. Therefore, it's not clear what IsText really means.

This property merely tells a reading application what is stored in the metadata for an entry, without guaranteeing its validity or its meaning.

When DotNetZip is used to create a zipfile, it attempts to set this field "correctly." For example, if a file ends in ".txt", this field will be set. Your application may override that default setting. When writing a zip file, you must set the property before calling Save() on the ZipFile.

When reading a zip file, a more general way to decide just what kind of file is contained in a particular entry is to use the file type database stored in the operating system. The operating system stores a table that says, a file with .jpg extension is a JPG image file, a file with a .xml extension is an XML document, a file with a .txt is a pure ASCII text document, and so on. To get this information on Windows, you need to read and parse the registry.

Examples
CopyC#
using (var zip = new ZipFile())
{
    var e = zip.UpdateFile("Descriptions.mme", "");
    e.IsText = true;
    zip.Save(zipPath);
}
CopyVB.NET
Using zip As New ZipFile
    Dim e2 as ZipEntry = zip.AddFile("Descriptions.mme", "")
    e.IsText= True
    zip.Save(zipPath)
End Using

Assembly: Ionic.Zip (Module: Ionic.Zip) Version: 1.9.1.8 (1.9.1.8)