- fileName (String)
- The name of the file, including any directory path, to retrieve from the zip. The filename match is not case-sensitive by default; you can use the CaseSensitiveRetrieval property to change this behavior. The pathname can use forward-slashes or backward slashes.
This property is read-only.
The CaseSensitiveRetrieval property on the ZipFile determines whether retrieval via this indexer is done via case-sensitive comparisons. By default, retrieval is not case sensitive. This makes sense on Windows, in which filesystems are not case sensitive.
Regardless of case-sensitivity, it is not always the case that this[value].FileName == value. In other words, the FileName property of the ZipEntry retrieved with this indexer, may or may not be equal to the index value.
This is because DotNetZip performs a normalization of filenames passed to this indexer, before attempting to retrieve the item. That normalization includes: removal of a volume letter and colon, swapping backward slashes for forward slashes. So, zip["dir1\\entry1.txt"].FileName == "dir1/entry.txt".
Directory entries in the zip file may be retrieved via this indexer only with names that have a trailing slash. DotNetZip automatically appends a trailing slash to the names of any directory entries added to a zip.
using (ZipFile zip = ZipFile.Read("PackedDocuments.zip")) { foreach (string s1 in zip.EntryFilenames) { if (s1.EndsWith(".txt")) zip[s1].Extract("textfiles"); } }
Using zip As ZipFile = ZipFile.Read("PackedDocuments.zip") Dim s1 As String For Each s1 In zip.EntryFilenames If s1.EndsWith(".txt") Then zip(s1).Extract("textfiles") End If Next End Using
Exception | Condition |
---|---|
ArgumentException |
Thrown if the caller attempts to assign a non-null value to the indexer.
|