File does not have a stream with WriteToDirectory with .7zip #685

Open
opened 2026-01-29 22:15:51 +00:00 by claunia · 2 comments
Owner

Originally created by @mathdx1111 on GitHub (Jul 8, 2025).

Hi, at my job we use this method for an automated job that is trigger when .7zip files are put inside a specific folder:

public void Executer(ref string pChaineContexte, XdCuContexteTravail pContexte)
{
    var dossierDepot = new XdCuFichier().ObtenirDepot(ref pChaineContexte, pContexte.NomChaine(ref pChaineContexte), "ReceptionSEEL");
    string[] fichiersZip = Directory.GetFiles(dossierDepot);
    foreach (var fichierZip in fichiersZip)
    {
        var fichierVide = string.Concat(dossierDepot, "\\", Path.GetFileNameWithoutExtension(fichierZip));
        Directory.CreateDirectory(fichierVide);

        using (var archive = ArchiveFactory.Open(fichierZip))
        {
            foreach (var entry in archive.Entries)
            {
                if (!entry.IsDirectory)
                    entry.WriteToDirectory(fichierVide, new ExtractionOptions() { ExtractFullPath = true, Overwrite = true });
            }
        }
    }
    return;
}

The problem is that I get a lot of the time this error: "File does not have a stream".
It does start the decompressing job but there is only one file that is in the new folder and nothing more. After we get the error that I mentionned.

I've read this: https://stackoverflow.com/questions/79455464/issue-partially-extracting-a-7-zip-archive-using-sharpcompress and I think this is a real issue.

Originally created by @mathdx1111 on GitHub (Jul 8, 2025). Hi, at my job we use this method for an automated job that is trigger when .7zip files are put inside a specific folder: ``` public void Executer(ref string pChaineContexte, XdCuContexteTravail pContexte) { var dossierDepot = new XdCuFichier().ObtenirDepot(ref pChaineContexte, pContexte.NomChaine(ref pChaineContexte), "ReceptionSEEL"); string[] fichiersZip = Directory.GetFiles(dossierDepot); foreach (var fichierZip in fichiersZip) { var fichierVide = string.Concat(dossierDepot, "\\", Path.GetFileNameWithoutExtension(fichierZip)); Directory.CreateDirectory(fichierVide); using (var archive = ArchiveFactory.Open(fichierZip)) { foreach (var entry in archive.Entries) { if (!entry.IsDirectory) entry.WriteToDirectory(fichierVide, new ExtractionOptions() { ExtractFullPath = true, Overwrite = true }); } } } return; } ``` The problem is that I get a lot of the time this error: "File does not have a stream". It does start the decompressing job but there is only one file that is in the new folder and nothing more. After we get the error that I mentionned. I've read this: [https://stackoverflow.com/questions/79455464/issue-partially-extracting-a-7-zip-archive-using-sharpcompress](url) and I think this is a real issue.
claunia added the enhancement label 2026-01-29 22:15:51 +00:00
Author
Owner

@adamhathcock commented on GitHub (Jul 9, 2025):

7Zip creates bundles of streams and entries are in that stream. This is different from all other formats other than RAR SOLID archives.

Essentially the linked SO solution is correct as it extracts everything from the 7ZIp archive as a single stream/SOLID.

@adamhathcock commented on GitHub (Jul 9, 2025): 7Zip creates bundles of streams and entries are in that stream. This is different from all other formats other than RAR SOLID archives. Essentially the linked SO solution is correct as it extracts everything from the 7ZIp archive as a single stream/SOLID.
Author
Owner

@mathdx1111 commented on GitHub (Jul 9, 2025):

7Zip creates bundles of streams and entries are in that stream. This is different from all other formats other than RAR SOLID archives.

Essentially the linked SO solution is correct as it extracts everything from the 7ZIp archive as a single stream/SOLID.

So for the moment, how can I change my code in order that SharpCompress can do the job?

@mathdx1111 commented on GitHub (Jul 9, 2025): > 7Zip creates bundles of streams and entries are in that stream. This is different from all other formats other than RAR SOLID archives. > > Essentially the linked SO solution is correct as it extracts everything from the 7ZIp archive as a single stream/SOLID. So for the moment, how can I change my code in order that SharpCompress can do the job?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/sharpcompress#685