Class XarFileEntry
Namespace: Aspose.Zip.Xar
Assembly: Aspose.Zip.dll (25.2.0)
Represents file entry within xar archive.
public sealed class XarFileEntry : XarEntry, IArchiveFileEntry
Inheritance
object ← XarEntry ← XarFileEntry
Implements
Inherited Members
XarEntry.ToString(), XarEntry.Name, XarEntry.FullPath, XarEntry.IsDirectory, XarEntry.Parent, XarEntry.CreationTime, XarEntry.LastAccessTime, XarEntry.LastWriteTime, XarEntry.ModificationTime, object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()
Properties
Length
Gets the length of the entry in bytes.
public long Length { get; }
Property Value
Methods
Extract(string)
Extracts the entry to the filesystem by the path provided.
public FileInfo Extract(string path)
Parameters
path
string
The path to destination file. If the file already exists, it will be overwritten.
Returns
The file info of composed file.
Examples
using (var archive = new XarArchive("archive.xar"))
{
((XarFileEntry)archive.Entries[0]).Extract("data.bin");
}
Exceptions
path
is null.
The caller does not have the required permission to access.
The path
is empty, contains only white spaces, or contains invalid characters.
Access to file path
is denied.
The specified path
, file name, or both exceed the system-defined maximum length. For example, on Windows-based platforms, paths must be less than 248 characters, and file names must be less than 260 characters.
File at path
contains a colon (:) in the middle of the string.
Archive is corrupted.
Extract(Stream)
Extracts the entry to the stream provided.
public void Extract(Stream destination)
Parameters
destination
Stream
Destination stream. Must be writable.
Examples
Extract an entry of xar archive.
using (var archive = new XarArchive("archive.xar"))
{
((XarFileEntry)archive.Entries[0]).Extract(httpResponseStream);
}
Exceptions
destination
does not support writing.
Archive is corrupted.
Open()
Opens the entry for extraction and provides a stream with entry content.
public Stream Open()
Returns
The stream that represents the contents of the entry.
Examples
Usage:
Stream decompressed = entry.Open();
.NET 4.0 and higher - use Stream.CopyTo method:
decompressed.CopyTo(httpResponse.OutputStream)
.NET 3.5 and before - copy bytes manually:
byte[] buffer = new byte[8192];
int bytesRead;
while (0 < (bytesRead = decompressed.Read(buffer, 0, buffer.Length)))
fileStream.Write(buffer, 0, bytesRead);
```</p>
#### Remarks
Read from the stream to get original content of file. See examples section.
### <a id="Aspose_Zip_Xar_XarFileEntry_CompressionProgressed"></a> CompressionProgressed
Raises when a portion of raw stream compressed.
```csharp
public event EventHandler<progresseventargs> CompressionProgressed
Event Type
EventHandler<ProgressEventArgs>
Examples
archive.Entries.First().CompressionProgressed += (s, e) => { int percent = (int)((100 * (long)e.ProceededBytes) / entrySourceStream.Length); };
Remarks
Event sender is an Aspose.Zip.Xar.XarFileEntry instance.