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 = ...
随机推荐
- 如何设置EditPlus的默认编码utf-8方式
最近在使用英文版的Editplus写代码的时候,发现中文字符在调试过程中都变成了乱码,发现是Editplus编码设置的问题,Editplus默认编码可能是ANSI,需要将其改成UTF-8.干脆给设置默 ...
- java this 隐式参数
第37级 this 是隐式参数, 类的方法调用时,会系统自动传递一个this的参数给方法.(这个参数是隐式传递的) 所以在方法里可以使用this这个参数. this在方法中表示对象. this(参数列 ...
- POJ - 1523 SPF
题目要求割顶集,并且还要求出去掉割顶之后剩下的图连通数目. tarjan算法求出割顶后直接枚举就可以了吧. 一开始想到利用iscut[u]的次数也就是点u被判定为割顶的次数求连通分量数,还有利用与结点 ...
- Android开发之通过Intent启动其他App的Service
在Android5.0以前可以通过隐式Intent方式启动其他App的Service,就跟Activity启动隐式Intent一样的. 但是在5.0以后,只能使用显示的Intent方式启动了. 启动其 ...
- Java开发所需架包官方下载
1.连接MySQL数据库所需架包点击进入官网下载 2.连接Oracle数据库所需架包点击进入官网下载 3.JUnit测试所需架包点击进入官网下载或者点击进入官网下载 4.Struts所需架包点击进入官 ...
- 基于Hadoop Sequencefile的小文件解决方案
一.概述 小文件是指文件size小于HDFS上block大小的文件.这样的文件会给hadoop的扩展性和性能带来严重问题.首先,在HDFS中,任何block,文件或者目录在内存中均以对象的形式存储,每 ...
- mapreduce实现全局排序
直接附代码,说明都在源码里了. package com.hadoop.totalsort; import java.io.IOException; import java.util.ArrayList ...
- .NET(C#)调用webService获取客户端IP地址所属区域(非异步)
功能描述: 此接口用于获取客户端访问的IP的地址所属的区域(国家,城市等).通过输入IP地址查询国家.城市.所有者等信息.没有注明国家的为中国输入参数:IP地址(自动替换 " ." ...
- Xcode 升级后, 插件无法使用的问题( PluginLoading: Required plug-in compatibility UUID.... )
find ~/Library/Application\ Support/Developer/Shared/Xcode/Plug-ins -name Info.plist -maxdepth 3 | x ...
- 1.进入debug模式(基础知识列表)
1.进入debug模式(基础知识列表)1.设置断点 2.启动servers端的debug模式 3.运行程序,在后台遇到断点时,进入debug调试状态 ========================= ...