Home Forums .NET libraries Xceed Zip & Real-Time Zip for .NET Recieve events from CopyFilesTo method

Viewing 2 posts - 1 through 2 (of 2 total)
  • Author
  • User (Old forums)
    Post count: 23064
    #19356 |

    Hi Guys,

    I’m trying to receive events using the zipevents and ziparchive class in asp.net , but no luck.
    Here is my code :

    Private WithEvents events As New ZipEvents()

    Private Sub cmdExtract_Click()

    ‘ Begin Extracting the zip file
    Response.Write(“Begin Extracting Zip Files”)
    zip.BeginUpdate(events, Nothing)
    zip.CopyFilesTo(folder, True, True)
    zip.EndUpdate(events, Nothing)

    End Sub

    the zip is extracted correctly , but no events are raised.
    What as I missing here?

    Imported from legacy forums. Posted by alonhr (had 2001 views)

    User (Old forums)
    Post count: 23064


    Calling BeginUpdate with a ZipEvents of FileSystemEvents instance does not register for events for all other method calls until EndUpdate, but only for possible events during this single phase (preparing for update). This is to avoid keeping references on the FileSystemEvents (or ZipEvents) after each method call.

    When you want to receive events, the rule is simple: everytime you call a method which can accept a FileSystemEvents, pass it. In your case, CopyFilesTo can accept one, so you should do:

    zip.BeginUpdate(events, Nothing)
    zip.CopyFilesTo(events, Nothing, folder, True, True)
    zip.EndUpdate(events, Nothing)

    And as a matter of fact, even when creating your ZipArchive instance, you should use the constructor that takes a ZipEvents.

    Imported from legacy forums. Posted by Martin (had 3246 views)

Viewing 2 posts - 1 through 2 (of 2 total)
  • You must be logged in to reply to this topic.