http://sevenzipsharp.codeplex.com/
MainWindow.xaml
<Window x:Class="SevenZipTestWPF.MainWindow"
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
Title="SevenZipSharp WPF Demo" Height="157" Width="479" WindowStartupLocation="CenterScreen" >
<Grid>
<Image x:Name="image1" HorizontalAlignment="Left" Height="20" Margin="-13,25,0,0" VerticalAlignment="Top" Width="193" Source="progress-filled1.png" Stretch="None" RenderTransformOrigin="0.5,0.5">
<Image.RenderTransform>
<TransformGroup>
<ScaleTransform ScaleX="0.75" ScaleY="0.73"/>
<SkewTransform/>
<RotateTransform/>
<TranslateTransform/>
</TransformGroup>
</Image.RenderTransform>
</Image>
<Grid>
<ProgressBar Height="15" HorizontalAlignment="Left" Margin="10,10,0,0"
Name="progressBar1" VerticalAlignment="Top" Width="355" />
<Button Content="Extract" HorizontalAlignment="Left" Margin="383,10,0,0" Name="b_Extract" Width="52" Click="b_Extract_Click" VerticalAlignment="Top" />
<Label x:Name="label1" Content="Label" HorizontalAlignment="Left" Margin="10,50,0,0" VerticalAlignment="Top" Width="451"/>
</Grid>
</Grid>
</Window>
MainWindow.xaml.cs
using System;
using System.Windows;
using SevenZip;
namespace SevenZipTestWPF
{
/// <summary>
/// Interaction logic for MainWindow.xaml
/// </summary>
public partial class MainWindow : Window
{
public MainWindow()
{
InitializeComponent();
Check7zAndSevenZipSharpDll();
}
private string fileName = @"D:\Administrator\wwwroot\CPW\wmgjUpdate.7z";
private string directory = @"D:\Administrator\Desktop\完美世界国际版";
private string dll7z = AppDomain.CurrentDomain.BaseDirectory + "7z.dll";
private string dllSevenZipSharp = AppDomain.CurrentDomain.BaseDirectory + "SevenZipSharp.dll";
private int MaxValue = 0;
private int CurrentValue = 0;
private void b_Extract_Click(object sender, RoutedEventArgs e)
{
if (System.IO.File.Exists(fileName) && System.IO.Directory.Exists(directory))
{
SevenZipExtractor.SetLibraryPath(dll7z);
label1.Content = "开始更新客户端文件";
var extractor = new SevenZipExtractor(fileName);
progressBar1.Maximum = extractor.ArchiveFileData.Count;
MaxValue = extractor.ArchiveFileData.Count;
extractor.FileExtractionStarted += new EventHandler<FileInfoEventArgs>(extr_FileExtractionStarted);
extractor.BeginExtractArchive(directory);
}
}
void extr_FileExtractionStarted(object sender, FileInfoEventArgs e)
{
label1.Content = String.Format("更新文件 {0}", e.FileInfo.FileName);
progressBar1.Value += 1;
CurrentValue += 1;
ImageProgressBar(CurrentValue, MaxValue, 193, image1);
if (progressBar1.Maximum == progressBar1.Value)
label1.Content = "游戏更新完成";
}
private void Check7zAndSevenZipSharpDll()
{
bool b1 = System.IO.File.Exists(dll7z);
bool b2 = System.IO.File.Exists(dllSevenZipSharp);
if (!b1)
{
MessageBox.Show("7z.dll 不存在!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
Close();
}
if (!b2)
{
MessageBox.Show("SevenZipSharp.dll 不存在!", "错误", MessageBoxButton.OK, MessageBoxImage.Error);
Close();
}
}
/// <summary>
/// 图片进度条
/// </summary>
/// <param name="current"></param>
/// <param name="max"></param>
/// <param name="imageWidth">图片的实际宽度</param>
/// <param name="image1"></param>
private static void ImageProgressBar(double current, double max, double imageWidth, System.Windows.Controls.Image image1)
{
if (max != 0)
image1.Width = System.Math.Round((current / max) * imageWidth);
}
}
}
- WPF 下载网络文件 带进度条
附件:http://files.cnblogs.com/xe2011/WpfApplication3_downloadFile.rar 使用 private void Button ...
- Asp.Net上传大文件带进度条swfupload
Asp.Net基于swfupload上传大文件带进度条百分比显示,漂亮大气上档次,大文件无压力,先看效果 一.上传效果图 1.上传前界面:图片不喜欢可以自己换 2.上传中界面:百分比显示 3.上传后返 ...
- Extjs 使用fileupload插件上传文件 带进度条显示
一.首先我们看看官方给出的插件的解释: 一个文件上传表单项具有自定义的样式,并且可以控制按钮的文本和 像文本表单的空文本类似的其他特性. 它使用一个隐藏的文件输入元素,并在用户选择文件后 在form提 ...
- ASP.NET Jquery+ajax上传文件(带进度条)
效果图 支持ie6+,chrome,ie6中文文件名会显示乱码. 上传时候会显示进度条. 需要jquery.uploadify.js插件,稍后会给出下载 前台代码 <%@ Page Langua ...
- Springmvc+uploadify实现文件带进度条批量上传
网上看了很多关于文件上传的帖子,众口不一,感觉有点乱,最近正好公司的项目里用到JQuery的uploadify控件做文件上传,所以整理下头绪,搞篇文档出来,供亲们分享. Uploadify控件的主要优 ...
- webclient下载文件 带进度条
private void button1_Click(object sender, EventArgs e) { doDownload(textBox1.Text.Trim()); } private ...
- asp.net mvc 实现上传文件带进度条
本文乃是博主早期写的,此种思路虽然实现了,但固然不是最好的,仅做参考学习. 可以用js onprogress .fileinput .webuploader.jq ajaxsubmit等实现 思路:a ...
- FormData上传文件 带进度条
* jQuery ajax FormData 上传文件 template $.ajax({ url: url, type: 'POST', data: new FormData(form), dat ...
- UrlDownloadFile, 线程下载文件, 带进度条
unit FileDownLoadThread; interface uses Classes, SysUtils, Windows, ActiveX, UrlMon; const S_ABORT = ...
随机推荐
- IgnoreRoute——注册路由
routes.IgnoreRoute("home/about"); 这句话,当Route遇到Home/About的Url时,这段URL将被忽略. 效果图 需要注意的是这里route ...
- MySQL db优化
http://blog.csdn.net/likika2012/article/details/38816037 http://www.nowamagic.net/librarys/veda/deta ...
- Django Aggregation聚合
在当今根据需求而不断调整而成的应用程序中,通常不仅需要能依常规的字段,如字母顺序或创建日期,来对项目进行排序,还需要按其他某种动态数据对项目进行排序.Djngo聚合就能满足这些要求. 以下面的Mode ...
- Shell编程学习---第五篇:Shell的输入和输出
在shell脚本中,可以用几种不同的方式读入数据:可以使用标准输入—缺省为键盘,或 者指定一个文件作为输入.对于输出也是一样:如果不指定某个文件作为输出,标准输出总 是和终端屏幕相关联.如果所使用命令 ...
- jQuery功能一览
// Hello world!"); }); $("#btn5").click(function(){ $("#test5").val("D ...
- poj3264Balanced Lineup(RMQ)
http://poj.org/problem?id=3264 RMQ讲解 http://dongxicheng.org/structure/lca-rmq/ j = log2K dp[i][j] = ...
- bzoj3503
显然知道第一行就可以只道整个矩阵但n<=40,搜索是不行的,我们设第一行为x1~xm可以由轻易由第一行未知数推出第n+1行,这一步我们可以压成二进制位(因为只和奇偶有关)显然n+1行必须是0,由 ...
- Android学习之路——简易版微信为例(三)
最近好久没有更新博文,一则是因为公司最近比较忙,另外自己在Android学习过程和简易版微信的开发过程中碰到了一些绊脚石,所以最近一直在学习充电中.下面来列举一下自己所走过的弯路: (1)本来打算前端 ...
- Rose
<html> <head> <title>JS小尝试</title> <meta http-equiv="Content-Type&qu ...
- 安装tcpreplay时报错:configure: error: libdnet not found
安装tcpreplay时报错configure: error: libdnet not found 解决方法: 下载包libdnet-1.8.tar.gz并安装,依次执行: ./configure m ...