Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get the name of a part when the volume changes (Multi-Volume) #358

Open
Headkillah opened this issue Mar 12, 2018 · 4 comments
Open

Comments

@Headkillah
Copy link

Is it possible to get the part-name of an entry while extracting it?

For example: I have a Multi-Volume with 20 parts (.rar - .r19)

I start the extracting and i need the name of the volume-part when the volume changes... Is this possible?

Hope that nobody blames me for this question, but i don´t have much knowledge with C#

@adamhathcock
Copy link
Owner

This would probably require the Reader to have knowledge of the current volume. It probably already does. Just need to expose it like CurrentEntry

Pull requests are welcome

@Headkillah
Copy link
Author

Thx for the help adam, i solved my problem :) After you give me a hint, i found here on github the fix for my problem.

I´m using the IArchive Interface and FilePartExtractionBeginEventArgs. And a little change in "FileInfoRarFilePart.cs". I´ve changed the part "return FileInfo.FullName" to "return FileInfo.Name" and removed the "File entry" thing :) For me it works PERFECT now .

@CrownParkComputing
Copy link

Can u post the link to your solution as I think this will help with my progress issue

@Headkillah
Copy link
Author

Headkillah commented Mar 29, 2018

ATM i have no link, put i can you post here a part of my solution. For me, it works very good. Don´t know if do this for you, too....

In "SharpCompress.Archives.Rar.FileInfoRarFilePart.cs" change it in this manner:

internal override string FilePartName
    {
        get
        {
            return FileInfo.Name;
            //return "Rar File: " + FileInfo.FullName
            //       + " File Entry: " + FileHeader.FileName;
        }
    }

The Rest i´ve done is made with vb.net, so you have to convert it to c#. And this is only a little part of the solution... And a little bit old code, because i´m not at home :D

This is the important thing... In my project Label11 is the Label wich shows the actual volume (e.g. "test.r08")

Private Sub archive_FilePartExtractionBegin(ByVal sender As Object, ByVal e As FilePartExtractionBeginEventArgs)
    Label11.Text = e.Name
End Sub

Private Sub PrintVolumes(ByVal ArchivePath As String)

    Using archive As IArchive = getIArchive(ArchivePath, Nothing)

        AddHandler archive.FilePartExtractionBegin, AddressOf archive_FilePartExtractionBegin

            For Each entry As IArchiveEntry In archive.Entries

                If Not entry.IsDirectory Then

                    Label3.Text = entry.Key
                    Label5.Text = entry.CompressedSize.ToString
                    Label7.Text = entry.Size.ToString
                    Label9.Text = archive.Volumes.Count.ToString

                    entry.WriteToDirectory(dest, Nothing)

                End If
            Next
        End If
    End Using
End Sub

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants