2
我得到了下面的代碼:C#Ionic.Zip進度爲背景工人
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;
}
}
當我點擊該按鈕,表格會被卡住。我想將ExtractProgress作爲背景工作者,但是當我不知道如何將函數轉換爲backgroundworker函數時,因爲ExtractProgress函數需要ExtractProgressEventArgs e,而backgroundworker_dowork函數需要DoWorkEventArgs e。
如果有人可以幫助我轉換它或給我另一個解決方案,它將是偉大的!
在這種情況下,我不知道該怎麼做:/ – Ron 2010-12-01 18:13:36