DeleteEntry

SharArchive.DeleteEntry method (1 of 2)

Removes the first occurrence of a specific entry from the entries list.

public SharArchive DeleteEntry(SharEntry entry)
ParameterTypeDescription
entrySharEntryThe entry to remove from the entries list.

Return Value

Shar entry instance.

Exceptions

exceptioncondition
ArgumentNullExceptionentry is null.

Examples

Here is how you can remove all entries except the last one:

using (var archive = new SharArchive("archive.shar"))
{
    while (archive.Entries.Count > 1)
        archive.DeleteEntry(archive.Entries[0]);
    archive.Save(outputSharFile);
}

See Also


SharArchive.DeleteEntry method (2 of 2)

Removes the entry from the entries list by index.

public SharArchive DeleteEntry(int entryIndex)
ParameterTypeDescription
entryIndexInt32The zero-based index of the entry to remove.

Return Value

The archive with the entry deleted.

Exceptions

exceptioncondition
ArgumentOutOfRangeExceptionentryIndex is less than 0.-or- entryIndex is equal to or greater than Entries count.

Examples

using (var archive = new SharArchive("two_files.shar"))
{
    archive.DeleteEntry(0);
    archive.Save("single_file.shar");
}

See Also