Share via

SharpCompress -Update from 0.445 to 0.46.3 produces error

Pip 265 Reputation points
2026-02-27T13:35:13.9366667+00:00

Hi,

I'm using class library of .NET 10.

<TargetFrameworks>net10.0</TargetFrameworks>

I update from 0.445 to 0.46.3 produces errorsUser's image

 using (var archive = ArchiveFactory.Open(archivePath))
 {
     var list = new List<string>();
     foreach (var entry in archive.Entries)

Error:

'ArchiveFactory' does not contain a definition for 'Open'

What to do?

Thanks in advance,

Developer technologies | C#
Developer technologies | C#

An object-oriented and type-safe programming language that has its roots in the C family of languages and includes support for component-oriented programming.

0 comments No comments
{count} votes

Answer accepted by question author
  1. Jack Dang (WICLOUD CORPORATION) 14,955 Reputation points Microsoft External Staff Moderator
    2026-03-02T08:11:48.8+00:00

    Hi @Pip ,

    Thanks for reaching out.

    In SharpCompress version 0.46.x, the Open() method was removed and replaced with OpenArchive() for synchronous usage and OpenAsyncArchive() for asynchronous usage. So that’s why your old code is now showing:

    'ArchiveFactory' does not contain a definition for 'Open'
    

    Here’s some guidance on choosing between them:

    • Small archive files or simple scenarios: use OpenArchive(). It behaves just like your old Open() method, everything happens step by step.
    • Large archive files or when you don’t want your app to freeze while loading: use OpenAsyncArchive() inside an async method with await. This lets your program do other things while the archive is being read.

    Example using synchronous OpenArchive():

    using var archive = ArchiveFactory.OpenArchive(archivePath);
    foreach (var entry in archive.Entries)
    {
        // process entries here
    }
    

    Example using asynchronous OpenAsyncArchive():

    public async Task ProcessArchiveAsync(string archivePath)
    {
        using var archive = await ArchiveFactory.OpenAsyncArchive(archivePath);
        foreach (var entry in archive.Entries)
        {
            // process entries here
        }
    }
    

    Note: Please use these code snippets as reference only, adjust them to fit your project’s structure, async/sync needs, and error handling.

    Hope this helps! If my answer was helpful - kindly follow the instructions here so others with the same problem can benefit as well.

    1 person found this answer helpful.

1 additional answer

Sort by: Most helpful
  1. Giovanni Savoretti 0 Reputation points
    2026-03-01T09:57:39.5633333+00:00

    Hi Pip,

    The Open() function has been replaced with two other functions: OpenArchive() and OpenAsyncArchive().

    Prefer OpenAsyncArchive() if you are working with an asynchronous method.


Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.