I got the following code:
string path = Environment.CurrentDirectory;
private void button1_Click(object sender, EventArgs e)
{
using (ZipFile zip = ZipFile.Read("Fringe.S03E07.HDTV.XviD-LOL.zip"))
{
zip.ExtractProgress += ExtractProgress;
foreach (ZipEntry file in zip)
{
file.Extract(path+"\\temp", ExtractExistingFileAction.OverwriteSilently);
}
}
}
public void ExtractProgress(object sender, ExtractProgressEventArgs e)
{
if (e.EventType == ZipProgressEventType.Extracting_EntryBytesWritten)
{
//bytes transfered of current file
label4.Text = e.BytesTransferred.ToString();
}
else if (e.EventType == ZipProgressEventType.Extracting_BeforeExtractEntry)
{
//filename of current extracted file
label2.Text = e.CurrentEntry.FileName;
}
}
when I click on the button, the form get stuck. I want to make the ExtractProgress as background worker but when I dont know how to convert the function to backgroundworker function because the ExtractProgress function require ExtractProgressEventArgs e and the backgroundworker_dowork function require DoWorkEventArgs e.
if someone can help me to convert it or to give me another solution it will be great!
Simple: just put all the code in button1_Click
into a method, and have button1_Click
run that method in a BackgroundWorker
. Try it and see how it works out.