Class IsoArchive

Class IsoArchive

Namespace: Aspose.Zip.Iso
Assembly: Aspose.Zip.dll (25.2.0)

Represents an ISO archive (ISO 9660).

public sealed class IsoArchive : IArchive, IDisposable

Inheritance

objectIsoArchive

Implements

IArchive, IDisposable

Inherited Members

object.GetType(), object.ToString(), object.Equals(object?), object.Equals(object?, object?), object.ReferenceEquals(object?, object?), object.GetHashCode()

Constructors

IsoArchive()

Initializes a new instance of the Aspose.Zip.Iso.IsoArchive class and creates an empty ISO archive for adding new files and directories.

public IsoArchive()

Examples

The following example shows how to create a new empty ISO archive and add files to it:

// Create a new empty ISO archive
using(IsoArchive isoArchive = new IsoArchive())
{
    // Add files to the ISO archive
    isoArchive.CreateEntry("example_file.txt", "path_to_file.txt");

    // Save the ISO archive to a file
    isoArchive.Save("new_archive.iso");
}

IsoArchive(Stream, IsoLoadOptions)

Initializes a new instance of the Aspose.Zip.Iso.IsoArchive class and composes entries list that can be extracted from the archive.

public IsoArchive(Stream sourceStream, IsoLoadOptions loadOptions = null)

Parameters

sourceStream Stream

The source of the archive. It must be seekable.

loadOptions IsoLoadOptions

The options to load archive with.

Examples

The following example shows how to extract all of the entries to a directory.

using (var archive = new IsoArchive(File.OpenRead("archive.iso")))
{ 
   archive.ExtractToDirectory("C:\\extracted");
}

Remarks

This constructor does not unpack any entry.

Exceptions

ArgumentNullException

sourceStream is null.

ArgumentException

sourceStream is not seekable.

InvalidDataException

sourceStream is not a valid ISO archive.

IsoArchive(string, IsoLoadOptions)

Initializes a new instance of the Aspose.Zip.Iso.IsoArchive class and composes entries list that can be extracted from the archive.

public IsoArchive(string path, IsoLoadOptions loadOptions = null)

Parameters

path string

The path to the archive file.

loadOptions IsoLoadOptions

The options to load archive with.

Examples

The following example shows how to extract all of the entries to a directory.

using (var archive = new IsoArchive("archive.iso")) 
{ 
   archive.ExtractToDirectory("C:\\extracted");
}

Remarks

This constructor does not unpack any entry.

Exceptions

ArgumentNullException

path is null.

SecurityException

The caller does not have the required permission to access.

ArgumentException

The path is empty, contains only white spaces, or contains invalid characters.

UnauthorizedAccessException

Access to file path is denied.

PathTooLongException

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.

NotSupportedException

File at path contains a colon (:) in the middle of the string.

FileNotFoundException

The file is not found.

DirectoryNotFoundException

The specified path is invalid, such as being on an unmapped drive.

IOException

The file is already open.

EndOfStreamException

File is too short.

Properties

Entries

Gets entries of Aspose.Zip.Iso.IsoEntry type constituting the archive.

public ReadOnlyCollection<isoentry> Entries { get; }

Property Value

ReadOnlyCollection<IsoEntry&gt;

Methods

CreateDirectory(string)

Adds a directory to the ISO image.

public IsoEntry CreateDirectory(string name)

Parameters

name string

Path of the directory in the ISO.

Returns

IsoEntry

The ISO entry composed.

Exceptions

InvalidOperationException

The archive is opened for extraction.

ArgumentNullException

name is null or empty.

CreateEntry(string, string)

Adds a file to the ISO image.

public IsoEntry CreateEntry(string name, string filePath)

Parameters

name string

Path of the file in the ISO.

filePath string

Path of the file.

Returns

IsoEntry

The ISO entry composed.

Exceptions

ArgumentNullException

The filePath is null.

ArgumentException

The filePath is empty, contains only white spaces, or contains invalid characters.

UnauthorizedAccessException

Access to file filePath is denied.

PathTooLongException

The specified filePath exceeds 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.

NotSupportedException

File at filePath contains a colon (:) in the middle of the string.

IOException

An I/O error occurred while opening the file.

CreateEntry(string, Stream)

Adds a file to the ISO image.

public IsoEntry CreateEntry(string name, Stream source)

Parameters

name string

Path of the file in the ISO.

source Stream

Stream containing the file data.

Returns

IsoEntry

The ISO entry composed.

CreateEntry(string)

Adds a file to the ISO image.

public IsoEntry CreateEntry(string name)

Parameters

name string

Path of the directory in the ISO.

Returns

IsoEntry

The ISO entry composed.

Exceptions

ArgumentNullException

name is null or empty.

InvalidOperationException

The archive is opened for extraction.

Dispose()

Performs application-defined tasks associated with freeing, releasing, or resetting unmanaged resources.

public void Dispose()

ExtractToDirectory(string)

Extracts all entries to the specified directory.

public void ExtractToDirectory(string destinationDirectory)

Parameters

destinationDirectory string

The directory to extract the entries to.

Examples

The following example shows how to extract all entries to a directory:

using (var archive = new IsoArchive(File.OpenRead("archive.iso")))
{ 
   archive.ExtractToDirectory("C:\\extracted");
}

Exceptions

InvalidOperationException

Thrown when the archive is in editing mode.

ArgumentNullException

Thrown when the destinationDirectory is null.

Save(string, IsoSaveOptions)

Saves the ISO image to the specified path.

public void Save(string path, IsoSaveOptions saveOptions = null)

Parameters

path string

The path where the ISO image will be saved.

saveOptions IsoSaveOptions

Options to save ISO archive with.

Examples

The following example shows how to save an ISO archive to a file:

// Create a new empty ISO archive
using(IsoArchive isoArchive = new IsoArchive())
{
    // Add files to the ISO archive
    isoArchive.CreateEntry("example_file.txt", "path_to_file.txt");

    // Save the ISO archive to a file
    isoArchive.Save("new_archive.iso");
}

Exceptions

InvalidOperationException

Thrown when the archive is not in editing mode.

ArgumentNullException

Thrown when the path is null.

DirectoryNotFoundException

Thrown when the specified path is invalid, such as being on an unmapped drive.

IOException

Thrown when the file is already open.

UnauthorizedAccessException

Thrown when access to the file path is denied.

PathTooLongException

Thrown when the specified path exceeds the system-defined maximum length.

Save(Stream, IsoSaveOptions)

Saves the ISO image to the specified stream.

public void Save(Stream stream, IsoSaveOptions saveOptions = null)

Parameters

stream Stream

The stream where the ISO image will be saved.

saveOptions IsoSaveOptions

Options to save ISO archive with.

Examples

The following example shows how to save an ISO archive to a memory stream:

// Create a new empty ISO archive
using(IsoArchive isoArchive = new IsoArchive())
{
    // Add files to the ISO archive
    isoArchive.CreateEntry("example_file.txt", "path_to_file.txt");

    // Save the ISO archive to a memory stream
    isoArchive.Save(memoryStream);
}

Exceptions

InvalidOperationException

Thrown when the archive is not in editing mode.

ArgumentNullException

Thrown when the stream is null.

ArgumentException

Thrown when the stream is not writable.

 English