FileName Property

DotNetZip

Ionic Zip Library v1.9.1.6 FileName Property
ReferenceIonic.ZipZipEntryFileName
The name of the file contained in the ZipEntry.
Declaration Syntax
C# Visual Basic Visual C++
public string FileName { get; set; }
Public Property FileName As String
	Get
	Set
public:
property String^ FileName {
	String^ get ();
	void set (String^ value);
}
Remarks

This is the name of the entry in the ZipFile itself. When creating a zip archive, if the ZipEntry has been created from a filesystem file, via a call to AddFile(String, String) or AddItem(String, String), or a related overload, the value of this property is derived from the name of that file. The FileName property does not include drive letters, and may include a different directory path, depending on the value of the directoryPathInArchive parameter used when adding the entry into the ZipFile.

In some cases there is no related filesystem file - for example when a ZipEntry is created using AddEntry(String, String) or one of the similar overloads. In this case, the value of this property is derived from the fileName and the directory path passed to that method.

When reading a zip file, this property takes the value of the entry name as stored in the zip file. If you extract such an entry, the extracted file will take the name given by this property.

Applications can set this property when creating new zip archives or when reading existing archives. When setting this property, the actual value that is set will replace backslashes with forward slashes, in accordance with the Zip specification, for compatibility with Unix(tm) and ... get this.... Amiga!

If an application reads a ZipFile via Read(String) or a related overload, and then explicitly sets the FileName on an entry contained within the ZipFile, and then calls Save()()()(), the application will effectively rename the entry within the zip archive.

If an application sets the value of FileName, then calls Extract() on the entry, the entry is extracted to a file using the newly set value as the filename. The FileName value is made permanent in the zip archive only after a call to one of the ZipFile.Save() methods on the ZipFile that contains the ZipEntry.

If an application attempts to set the FileName to a value that would result in a duplicate entry in the ZipFile, an exception is thrown.

When a ZipEntry is contained within a ZipFile, applications cannot rename the entry within the context of a foreach (For Each in VB) loop, because of the way the ZipFile stores entries. If you need to enumerate through all the entries and rename one or more of them, use ZipFile.EntriesSorted as the collection. See also, ZipFile.GetEnumerator().

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