Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

ZipArchive should document limitation on concurrent entry creation #11528

Open
@DL444

Description

@DL444

Type of issue

Missing information

Description

ZipArchive currently does not allow concurrent entry creation, and doing so results inIOException being thrown at run time. For example:

usingSystem.IO.Compression;usingMemoryStreammemoryStream=new();usingZipArchivearchive=new(memoryStream,ZipArchiveMode.Create);Task[]tasks=newTask[32];for(inti=0;i<tasks.Length;i++){tasks[i]=CreateEntryAsync(archive);}awaitTask.WhenAll(tasks).ConfigureAwait(false);staticasyncTaskCreateEntryAsync(ZipArchivezipArchive){ZipArchiveEntryentry=zipArchive.CreateEntry(Path.GetRandomFileName());usingStreamstream=entry.Open();awaitTask.Delay(100);// Simulate asynchronous write}

throws:

Unhandled exception. System.IO.IOException: Entries cannot be created while previously created entries are still open.   at System.IO.Compression.ZipArchive.AcquireArchiveStream(ZipArchiveEntry entry)   at System.IO.Compression.ZipArchive.DoCreateEntry(String entryName, Nullable`1 compressionLevel)   at System.IO.Compression.ZipArchive.CreateEntry(String entryName)   at Program.<<Main>$>g__CreateEntryAsync|0_0(ZipArchive zipArchive) in Program.cs:line 14   at Program.<Main>$(String[] args) in Program.cs:line 10   at Program.<Main>(String[] args)

While the limitation itself is understandable, I think it should be pointed out by the documentation. Right now neither the Exceptions section nor the Remarks section mentions this behavior.

Page URL

https://learn.microsoft.com/en-us/dotnet/api/system.io.compression.ziparchive.createentry?view=net-9.0

Content source URL

https://github.com/dotnet/dotnet-api-docs/blob/main/xml/System.IO.Compression/ZipArchive.xml

Document Version Independent Id

6edb630b-4e65-bdf8-8efd-cb5974682887

Platform Id

5bc53832-8985-3cc1-93b6-79225f7fb140

Article author

@dotnet-bot

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp