Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 637701
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T20:39:10+00:00 2026-05-13T20:39:10+00:00

I am trying to use SevenZipSharp or/and Unrar library in C# WinForms .NET 3.5.

  • 0

I am trying to use SevenZipSharp or/and Unrar library in C# WinForms .NET 3.5. I have this problem with multi rar archives that have diffrent naming for example:

  • .rar, r01, r02, r03 and so on (this is easy)
  • somefile01.rar, somefile02.rar, somefile03.rar

  • .001, .002, 003 and so on.

If i point Unrar or SevenZipSharp to wrong archive it will unpack that particular archive and leave rest unpacked. So i have to point the right one (unless i am doing something wrong).

What would be the best way to check for that? For now i am checking if there are more then one .rar files inside directory then if so i check for 01.rar. If there’s only one and .rar and couple of r01 then i get .rar but this seems a bit wrong.

Is there a way to make SevenZip or Unrar to actually unpack whole multi rar pack just by pointing to any .rar file? or .001 ?

MadBoy

EDIT:

I tried to use following code to get information as suggested in one answer but it fails to deliver promised information. extr.ArchiveFileData returns 0 for zip, and 32 for any provided rar whether it’s rar or r01.

        using (SevenZipExtractor extr = new SevenZipExtractor(fileName)) {

            foreach (var var in  extr.ArchiveProperties) {
                string attributes = var.Name;
                object test = var.Value;
                if (test == null) {
                    test = "THIS";
                } 
                MessageBox.Show(attributes.ToString(), test.ToString());
            }
                            foreach (var var in extr.ArchiveFileData) {
               MessageBox.Show(var.Attributes.ToString());
            }
        }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T20:39:10+00:00Added an answer on May 13, 2026 at 8:39 pm

    I believe that you could use SevenZipExtractor.ArchiveFileData property and then iterate through header data to find the relevant information.

    Part of the RAR header structure :

    HEAD_FLAGS Bit flags: 2 bytes

                0x0001  - Volume attribute (archive volume)
                0x0002  - Archive comment present
                          RAR 3.x uses the separate comment block
                          and does not set this flag.
    
                0x0004  - Archive lock attribute
                0x0008  - Solid attribute (solid archive)
                0x0010  - New volume naming scheme (\'volname.partN.rar\')
                0x0020  - Authenticity information present
                          RAR 3.x does not set this flag.
    
                0x0040  - Recovery record present
                0x0080  - Block headers are encrypted
                0x0100  - First volume (set only by RAR 3.0 and later)
    
                other bits in HEAD_FLAGS are reserved for
                internal use
    

    Edit :

    When I downloaded SevenZipSharp(1 hour ago) and found that SevenZipExtractor class contains a property that lists every file in volume (VolumeFileNames). I thought ‘Great! That was easy!’, well… it’s never that easy. It seems that VolumeFileNames works perfectly but only if you point it to the first rar in volume 🙁

    The wokraround :

    I’ve created a method to guess and verify the first volume :

    private static string LocateFirstVolume(string filename)
    {
        var isVolume = false;
        var parts = 1u;
    
        using (var extractor = new SevenZipExtractor(filename))
        {
            isVolume =
                extractor.ArchiveProperties.Any(x =>
                    x.Name.Equals("IsVolume") && x.Value.Equals(true));
    
            parts = (
                from x in extractor.ArchiveProperties
                where x.Name.Equals("Number of volumes")
                select (uint)x.Value).DefaultIfEmpty(1u).SingleOrDefault();
        }
    
        if (!isVolume)
            return null;
    
        if (parts > 1)
            return filename;
    
        if (!Path.GetExtension(filename)
            .Equals(".rar", StringComparison.OrdinalIgnoreCase))
        {
            var rarFile = 
                Path.Combine(
                    Path.GetDirectoryName(filename), 
                    Path.GetFileNameWithoutExtension(filename) + ".rar");
    
            if (File.Exists(rarFile))
            {
                var firstVolume = LocateFirstVolume(rarFile);
    
                if (firstVolume != null)
                {
                    return firstVolume;
                }
            }
        }
    
        var directoryFiles = Directory.GetFiles(Path.GetDirectoryName(filename));
    
        foreach (var directoryFile in directoryFiles)
        {
            var firstVolume = LocateFirstVolume(directoryFile);
    
            if (firstVolume != null)
            {
                using (var extractor = new SevenZipExtractor(firstVolume))
                {
                    if (extractor.VolumeFileNames.Contains(filename))
                    {
                        return firstVolume;
                    }
                }
            }
        }
    
        return null;
    }
    

    It’s quick&dirty but works and you can refine it further according to your needs.

    I hope this helps.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am trying use MySql and Entity Framework, using Connector/Net 6.1 with this as
I'm trying use eco for client-side templating. I have multiple .eco templates that I'd
I have a regex that I'm trying use to validate against strings. Trying to
I have a 3rd party DLL that I am trying to use in a
I am trying use Thread but i have some problem (I am beginner at
Hi I'm trying use a datepicker on a field I have. I'm trying to
Trying to use this method (gist of which is use self.method_name in the FunnyHelper
Trying to use this code to connect the AD PrincipalContext context = new PrincipalContext(ContextType.Domain,
trying to use this route: from(activemq:profiles).aggregate(header(cheese)).batchSize(30).bean(ProfilesQueueService, saveContacts) Fails with: No signature of method: org.apache.camel.model.RouteType.aggregate()
I have been trying use the edit_post_link() function to contain an image. All of

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.