B4J Question archiver UnZip

Arnaud

Active Member
Licensed User
Longtime User
Hello,

I cannot unzip a zip file, I don't know why. It works with many other zip files but not this (zip file in attachment).

Can you help me please?

Thanks

import and unzip zip file:
Sub ButtonImporter_MouseClicked (EventData As MouseEvent)

        Dim FC As FileChooser
        FC.Initialize
        FC.InitialDirectory = File.dirData("ALFANO SOFTWARE")' GetSystemProperty("user.dir","D:\")
        FC.setExtensionFilter(".zip", Array As String("*.zip", "*.zip"))
    
        FC.Title = CodeDivers.WordAndroidCSV(502) & " (.zip)"
        Dim l As List
        l=FC.ShowOpenMultiple(MainForm)

        Dim chemin As String
        Dim namefile As String

        If l.IsInitialized=True Then
        
            chemin=getFilePath(l.Get(0))
            Log(chemin)
        
            For i=0 To l.Size-1
            
                namefile=getFileName(l.Get(i))
                Log(namefile)
                
                    
                    Dim ArchiverZip As Archiver
                    Private nom_du_zip As String
                    nom_du_zip=namefile
                    
                    Private s1 As String
                    s1=namefile.Replace(".zip","")
                    
                    File.MakeDir(File.dirData("ALFANO SOFTWARE"),s1)

                    ArchiverZip.UnZip(chemin,nom_du_zip , File.dirData("ALFANO SOFTWARE") & "\" & s1  ,"")
                    

            Next

        End If

End Sub
 

Attachments

  • ALFANO6_LAP_SN6301_080722_15H07_Mathieu_CIRCUIT_DE_LOMMERANGE_8_3420.zip
    79.3 KB · Views: 111

Arnaud

Active Member
Licensed User
Longtime User
ohhhhh !

Thanks for your feedback !

I have received this file from a customer. How can I know if it is a valid archive file or not please? I would like improve my program to avoid this.
 
Upvote 0

kimstudio

Active Member
Licensed User
Longtime User
Strange I have other de/compression tool and it can open it showing file info as zip. My Windows 11 explorer can't. Maybe newest zip format?
 
Last edited:
Upvote 0

Arnaud

Active Member
Licensed User
Longtime User
I have received the "correct" zip file now. So I can compare the both (the old erroneous and the new who is ok). In attachment a picture of the properties between the both zip file.
 

Attachments

  • Capture d’écran 2022-07-21 150245.png
    Capture d’écran 2022-07-21 150245.png
    45 KB · Views: 90
  • Capture d’écran 2022-07-21 150426.png
    Capture d’écran 2022-07-21 150426.png
    27.4 KB · Views: 94
Upvote 0

agraham

Expert
Licensed User
Longtime User
As @Xfood remarked it looks like an rtfd file. If you open it as a binary file the first four bytes are 'rtfd'. A zip file will usually have 'PK' as the first two bytes followed by the ETX and EOT control characters. Other types of archive will have other identifiers. You will have to investigate the types of file you will accept and find ways of verifying their type.
 
Upvote 0
Top