473,471 Members | 1,695 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

DotNetZip extraction progress reporting\event help

6 New Member
Hi All.

Could someone give me some advice on reporting progress from a zip extraction using the DotNetZip Library?

I'm not an experienced programmer so having trouble understanding this.

I've created an event to report the progress (ProgressEventHandler) but the progress bar is still not updating.

The ExtractProgressEventArgs class TotalBytesToTransfer and BytesTransferred which I believe I need to use to set the maximum and increment value of the progress bar.

I'm trying to report the whole extraction (Resulting in a smooth progress bar for the whole unzip) rather than a steped progress bar per file as the examples given on the DotNetZip site.

So far I have:

Expand|Select|Wrap|Line Numbers
  1. Imports Ionic.Zip
  2. Imports System.Threading
  3. Imports System.Reflection
  4.  
  5. Public Class Form1
  6.  
  7.     Dim zipfileName As String = "C:\Test\test123.zip"
  8.     Dim extractDirectory As String = "C:\Test\"
  9.     Private Delegate Sub UpdateProgressBarInvoker(ByVal Value As Integer)
  10.  
  11.     Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
  12.     End Sub
  13.  
  14.     Private Sub Unzip()
  15.         Dim args(2) As String
  16.         args(0) = Me.zipfileName
  17.         args(1) = Me.extractDirectory
  18.         Dim t = New Thread(AddressOf Me.UnzipFile)
  19.         t.Start(args)
  20.         While Me.BackgroundWorker1.IsBusy
  21.             ' Keep UI messages moving, so the form remains 
  22.             ' responsive during the asynchronous operation.
  23.             Application.DoEvents()
  24.         End While
  25.     End Sub
  26.  
  27.     Private Sub UnzipFile(ByVal args As String())
  28.         Using zip As ZipFile = ZipFile.Read(args(0))
  29.             AddHandler zip.ExtractProgress, AddressOf ProgressEventHandler
  30.  
  31.             Dim entry As ZipEntry
  32.             For Each entry In zip
  33.                 entry.Extract(args(1), ExtractExistingFileAction.OverwriteSilently)
  34.             Next
  35.         End Using
  36.     End Sub
  37.  
  38.     Private Sub ProgressEventHandler(ByVal sender As Object, ByVal e As ExtractProgressEventArgs)
  39.         SetControlPropertyValue(ProgressBar1, "Maximum", e.TotalBytesToTransfer)
  40.         SetControlPropertyValue(ProgressBar1, "value", e.BytesTransferred)
  41.     End Sub
  42.  
  43.  
  44.  
  45.  
  46.     Delegate Sub SetControlValueCallback(ByVal oControl As Control, ByVal propName As String, ByVal propValue As Object)
  47.  
  48.     Private Sub SetControlPropertyValue(ByVal oControl As Control, ByVal propName As String, ByVal propValue As Object)
  49.         If (oControl.InvokeRequired) Then
  50.  
  51.             Dim d As New SetControlValueCallback(AddressOf SetControlPropertyValue)
  52.             oControl.Invoke(d, New Object() {oControl, propName, propValue})
  53.         Else
  54.             Dim t As Type = oControl.[GetType]()
  55.             Dim props As PropertyInfo() = t.GetProperties()
  56.             For Each p As PropertyInfo In props
  57.                 If p.Name.ToUpper() = propName.ToUpper() Then
  58.                     p.SetValue(oControl, propValue, Nothing)
  59.                 End If
  60.             Next
  61.         End If
  62.     End Sub
  63.  
  64.     Private Sub BtnUnzip_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles BtnUnzip.Click
  65.         Unzip()
  66.     End Sub
  67.  
  68. End Class
  69.  

I'm using examples from here(Half way down):
http://dotnetzip.codeplex.com/wikipage?title=VB-Examples&referringTitle=Examples

Thank you in advance.
Jun 16 '10 #1
0 1623

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: svilen | last post by:
hello again. i'm now into using python instead of another language(s) for describing structures of data, including names, structure, type-checks, conversions, value-validations, metadata etc....
0
by: Howell, Scott | last post by:
I am looking for a simple extraction/load program to load data daily from a Progress 8.3B database via ODBC to a mysql 3.23.57 database. It does not necessarily need to do any data-type...
9
by: Popoxinhxan | last post by:
Dear experts, i want to develop an client application that consume the google search web service. In my MainForm i have a method to retrieve all the search result e.g. GetGoogleResults(). Now i...
3
by: Tim::.. | last post by:
Can someone please, please tell me how I get a progress bar to work with a binary file upload! I have the following code that uploads files into an SQL Database using a Stored Procedure but I...
2
by: Dr_PoLish (the schnitzel) | last post by:
Hey, I've been developing an app that would basically clone the functionality that apt-get does for debian and port it to windows. Yes, the whole deal - repositories, .deb clones (in this case,...
1
by: b0red | last post by:
Hi All, Thanks for taking the time to read this post, I appreciate it. Two problems Problem 1 --------- I need help with a query the table contains 35 odd columns I only want fname,...
3
by: dec01louis | last post by:
Hi all, actually i'm now doing something on license plate recognition system for my project. The first step would be the license plate extraction algorithm which means it is needed to extract a...
5
matrekz42
by: matrekz42 | last post by:
Hello there, I currently have a form that has a button to run multiple queries and I want to add a bar to show the user the progress. I tried using the Microsoft Progress Bar Control 6.0, but I'm...
7
by: Atrox | last post by:
Hi, I'm fairly new to Visual Basic and am having problems getting the progress bar to work. I swap about 12 5-15MB files regularly to suit my needs and want to do this automatically. Ive only been...
5
by: progvar | last post by:
Hi, i want to know how to unzip a zip file and extract the files to a particular location please help me thanks in advance varinder
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.