ZipErrorAction.Skip doesn`t work for me

Dec 14, 2010 at 10:38 AM

Hello

I try to code an app for back up my files.

I have a checked Listbox item where i add or remove files that i want to zip practically it contains the paths to my files.

Let`s say that a file is missing on my hdd but it still has the path in checked ListBox and when zip sub is called it give me an error : "The file or directory does not exist !"

I tried to use zip.ZipErrorAction = ZipErrorAction.Skip to skip the missing files but it keeps to return the same error.

My code looks like :

Imports Ionic.Zip
Module subrutine
Public Sub zip()
        Call stergeZip()
        Try
            If index.listaFisiere.Items.Count <> 0 Then
                Using zip As ZipFile = New ZipFile()
                    
zip.ZipErrorAction = ZipErrorAction.Skip

                    For Each item In index.listaFisiere.Items
                        zip.AddItem(item)
                    Next
                    zip.Save(numeArhiva)
                    zip.Dispose()
                End Using
                If My.Settings.FTPPornit = True Then Call ftp()
                If My.Settings.HDDPornit = True Then Call hdd()
                If My.Settings.mailPornit = True Then Call mail()
                With index.balon
                    .BalloonTipText = "Back up efectuat cu succes !"
                    .BalloonTipIcon = ToolTipIcon.Info
                    .ShowBalloonTip(1000)
                End With
            Else
                MsgBox("Lista fisiserelor nu contine niciun obiect")
            End If
        Catch Ex As Exception
            MsgBox(Ex.Message)
            With index.balon
                .BalloonTipText = "Back up esuat !"
                .BalloonTipIcon = ToolTipIcon.Error
                .ShowBalloonTip(1000)
            End With
        End Try
    End Sub
End Module

Coordinator
Dec 17, 2010 at 7:00 PM

Hmm, that's an interesting case.  I'll file a bug and fix that, some way.

In the meantime you can avoid the problem completely by inserting a test for file existence before calling Zip.AddItem(). 

like this:

If (System.IO.File.Exists(item)) Then
    zip.AddItem(item)
End If
Coordinator
Dec 17, 2010 at 7:02 PM
This discussion has been copied to a work item. Click here to go to the work item and continue the discussion.
Dec 21, 2010 at 6:56 PM

Thank you. With your code mine program does what it should. Thank you again.