Android Question create multiple .zip files

fanfalveto

Active Member
Licensed User
Longtime User
I'm trying to put in separate files .zip the images contained in file.dirrootexternal / pics / these .zip be more or less a function of the number of images.
Anyway, make several. Zip but always with the same images inside.
zip files. might not be over 3.6 Mb and and a maximum of 20 files within the .zip
Any ideas please?
thanks
B4X:
Sub imagenesrecibidas
If fo=1 Then
Try
Log ("entra a alas imagenes recibidas")
Dim List2 As List
List2.Initialize
Dim List3 As List
List3.Initialize
Dim fil As List

fil.Initialize
Dim dire As String
dire=File.DirRootExternal & "/pics/"
List2=File.ListFiles(dire)
If List2.Size=0 Then
Log ("no hay nada")
Return
End If
fil.AddAll(List2)
'Log(fil)
Dim fotolist(fil.Size) As String

'Log (n)
Log(fil.Size)
fil.Sort(False)

fil.RemoveAt(0)
List3.AddAll(fil)
'Log(List3)
Log(List3.Size)
'Do While aa<n
Dim cuantas As Int=List3.Size
Dim total As Int

If cuantas >20 Then
total=20
Else
total=cuantas
End If
Dim fotolist22(total) As String
Dim loto As Long
Dim a As Int
Dim ii As Int
For x=0 To cuantas/15
a=a+1


For pp= ii To total-1
    fotolist(pp)=List3.Get(ii+pp)
    Log(fotolist(pp))
    Dim lo As Long
    lo=File.Size(File.DirRootExternal&"/pics/",fotolist(pp))
        If lo<3600000 Then
                If loto<3600000 Then
                    loto=loto+lo
                    fotolist22(pp)= (fotolist(pp))
                   
'                    Log(fotolist22(pp))
                    Log ("tamaño 1  "&File.Size(File.DirRootExternal&"/pics/",fotolist22(pp)))
                    'List3.RemoveAt(pp)
                        Else
                                If fotolist(pp).EndsWith("ent") Then
                                    fotolist22(pp)="null"
                                End If
                            fotolist22(pp)="null"
                End If
            Else
                fotolist22(pp)="null"
        End If
       
        ii=ii+1
Next

Try

Arc.AsyncZipFiles(File.DirRootExternal&"/pics/ Images/",fotolist22,File.DirRootExternal,"imagenesrecibido"&a&".zip","comprimir")
Log("tamaño    "&File.Size(File.DirRootExternal&"/","imagenesrecibido"&a&".zip"))
Catch
End Try
smm.Initialize("smtp.gmail.com",465,funcio1&"@gmail.com",funcio2,"smtpp"&ii)
smm.UseSSL=True
smm.To.Add(funcio1&"@gmail.com")
smm.Subject="imagenes recibidos"&a
smm.Body="imagenes recibidos"
smm.AddAttachment(File.DirRootExternal,"imagenesrecibido"&a&".zip")
smm.Send
Next

Catch
End Try

End If
End Sub
 

fanfalveto

Active Member
Licensed User
Longtime User
Whit this
B4X:
Sub imagenesrecibidas

If fo=1 Then

Log ("entra a alas imagenes recibidas")
a=0
Dim List2 As List
List2.Initialize
Dim List3 As List
List3.Initialize
Dim fil As List

fil.Initialize
Dim dire As String
dire=File.DirRootExternal & "/pics/"
List2=File.ListFiles(dire)
If List2.Size=0 Then

Return
End If
fil.AddAll(List2)

Dim fotolist(fil.Size) As String

fil.Sort(False)

fil.RemoveAt(0)
List3.AddAll(fil)

Dim cuantas As Int=List3.Size
Dim total As Int

If cuantas >15 Then
total=15
Else
total=cuantas
End If

Dim r As Int=0
Dim fotolist22(total) As String

For x=0 To cuantas/14
a=a+1
If loto>3600000 Then
loto=0
End If
r=0
For cc= x*13 To x*13+14

    Dim lo As Long
    lo=File.Size(File.DirRootExternal&"/pics/",fotolist(cc))
        If lo<3600000 Then
                If loto<3600000 Then
                    loto=loto+lo

                    fotolist22(r)= (fotolist(cc))

                    Log(fotolist22(r))

                        Else
                                If fotolist22(r).EndsWith("ent") Then
                                    fotolist22(r)="null"
                                End If
                            fotolist22(r)="null"
                End If
            Else
                fotolist22(r)="null"
        End If

        r=r+1
        Next

        Arc.AsyncZipFiles(File.DirRootExternal&"/pics/",fotolist22,File.DirRootExternal,"imagenesrecibido"&a&".zip","comprimir")
Log("tamaño    "&File.Size(File.DirRootExternal&"/","imagenesrecibido"&a&".zip"))

Next

End If
End Sub


Sub comprimir_ZipDone(CompletedWithoutError As Boolean, NbOfFiles As Int)
If    CompletedWithoutError=True Then
loto=0
Log ("ok al comprimir")
manda
Else
Log ("fallo al comprimir")
End If
End Sub

Sub manda
Log ("entra a enviar")
b=b+1
smm.Initialize("smtp.gmail.com",465,funcio1&"@gmail.com",funcio2,"smtpp")
smm.UseSSL=True
smm.To.Add(funcio1&"@gmail.com")
smm.Subject="imagenes recibidos"&b
smm.Body="imagenes recibidos"
smm.AddAttachment(File.DirRootExternal,"imagenesrecibido"&b&".zip")
smm.Send
End Sub

Create multiples zips (5) .Ok
B4X:
For x=0 To cuantas/14
But must be each zip with 14 pics.Not Ok
B4X:
For cc= x*13 To x*13+14
and put into 6,5,5,7 and 5
there aren´t any error in log,but in debug mode i see
in
B4X:
Arc.AsyncZipFiles(File.DirRootExternal&"/pics/",fotolist22,File.DirRootExternal,"imagenesrecibido"&a&".zip","comprimir")
that
B4X:
Ignoring event: comprimir_zipprogression. Raised from the wrong thread.
 
Last edited:
Upvote 0
Top