Save

CpioArchive.Save method (1 of 2)

Saves archive to destination file provided.

public void Save(string destinationFileName, CpioFormat cpioFormat = CpioFormat.OldAscii)
ParameterTypeDescription
destinationFileNameStringThe path of the archive to be created. If the specified file name points to an existing file, it will be overwritten.
cpioFormatCpioFormatDefines cpio header format.

Exceptions

exceptioncondition
ArgumentExceptiondestinationFileName is a zero-length string, contains only white space, or contains one or more invalid characters as defined by System.IO.Path.InvalidPathChars.
ArgumentNullExceptiondestinationFileName is null.
PathTooLongExceptionThe specified destinationFileName, 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.
DirectoryNotFoundExceptionThe specified destinationFileName is invalid, (for example, it is on an unmapped drive).
IOExceptionAn I/O error occurred while opening the file.
UnauthorizedAccessExceptiondestinationFileName specified a file that is read-only and access is not Read.-or- path specified a directory.-or- The caller does not have the required permission.
NotSupportedExceptiondestinationFileName is in an invalid format.

Remarks

It is possible to save an archive to the same path as it was loaded from. However, this is not recommended because this approach uses copying to temporary file.

Examples

using (var archive = new CpioArchive())
{
    archive.CreateEntry("entry1", "data.bin");        
    archive.Save("archive.cpio");
}       

See Also


CpioArchive.Save method (2 of 2)

Saves archive to the stream provided.

public void Save(Stream output, CpioFormat cpioFormat = CpioFormat.OldAscii)
ParameterTypeDescription
outputStreamDestination stream.
cpioFormatCpioFormatDefines cpio header format.

Exceptions

exceptioncondition
ArgumentNullExceptionoutput is null.
ArgumentExceptionoutput is not writable. - or - output is the same stream we extract from. - OR - It is impossible to save archive in cpioFormat due to format restrictions.

Remarks

output must be writable.

Examples

using (FileStream cpioFile = File.Open("archive.cpio", FileMode.Create))
{
    using (var archive = new CpioArchive())
    {
        archive.CreateEntry("entry1", "data.bin");        
        archive.Save(cpioFile);
    }
}       

See Also