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
Implements
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
sourceStream
is null.
sourceStream
is not seekable.
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
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.
The file is not found.
The specified path is invalid, such as being on an unmapped drive.
The file is already open.
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>
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
The ISO entry composed.
Exceptions
The archive is opened for extraction.
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
The ISO entry composed.
Exceptions
The filePath
is null.
The filePath
is empty, contains only white spaces, or contains invalid characters.
Access to file filePath
is denied.
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.
File at filePath
contains a colon (:) in the middle of the string.
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
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
The ISO entry composed.
Exceptions
name
is null or empty.
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
Thrown when the archive is in editing mode.
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
Thrown when the archive is not in editing mode.
Thrown when the path
is null.
Thrown when the specified path is invalid, such as being on an unmapped drive.
Thrown when the file is already open.
Thrown when access to the file path
is denied.
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
Thrown when the archive is not in editing mode.
Thrown when the stream
is null.
Thrown when the stream
is not writable.