C#:SevenZipSharp使用7z.dll来进行压缩与解压缩
1 点击上面的地址,打开下载页面
2 点击"普通下载"--等待30秒--点击"下载"按钮--保存
程序运行截图如下:
使用7z.dll来解压文件
选择解压到何处
解压完毕。
添加需要压缩的文件
选择保存路径
压缩完毕的提示。
主要源程序:
[csharp]
/*
* Created by SharpDevelop.
* User: Administrator
* Date: 2012/10/29
* Time: 16:13
*
* To change this template use Tools | Options | Coding | Edit Standard Headers.
*/
using System;
using System.Collections.Generic;
using System.Drawing;
using System.Windows.Forms;
using SevenZip;
using SevenZipSharp;
namespace SevenZipSharp
{
/// <summary>
/// Description of MainForm.
/// </summary>
public partial class MainForm : Form
{
SevenZip.SevenZipExtractor extractor = null;
SevenZipCompressor compressor = new SevenZipCompressor();
public MainForm()
{
//
// The InitializeComponent() call is required for Windows Forms designer support.
//
InitializeComponent();
//
// TODO: Add constructor code after the InitializeComponent() call.
//
this.label1.Text = "Please choose a archive to extract at first.";
this.label5.Text = "0";
this.label2.Text = "";
this.label3.Text = "";
this.listBox1.Items.Clear();
this.listBox2.Items.Clear();
}
void ShowException(string msg){
MessageBox.Show(msg,"Exception!",MessageBoxButtons.OK,MessageBoxIcon.Exclamation);
}
void ShowInformation(string msg){
MessageBox.Show(msg,"Information!",MessageBoxButtons.OK,MessageBoxIcon.Information);
}
void BtnBrowseCompressedFileClick(object sender, EventArgs e)
{
try{
OpenFileDialog ofd = new OpenFileDialog();
ofd.Filter = "ZIP File(*.zip)|*.zip|RAR File(*.rar)|*.rar";
if(ofd.ShowDialog() == DialogResult.OK){
string archiveFullName = ofd.FileName;
extractor = new SevenZipExtractor(archiveFullName);
extractor.ExtractionFinished += delegate {
this.label1.Text = "Extraction Finished.";
};
extractor.Extracting += delegate {
this.label1.Text = "Extracting, please wait...";
};
extractor.FileExtractionStarted += delegate {
this.label1.Text = "Start extracting...";
};
this.label5.Text = extractor.FilesCount.ToString();
this.label2.Text = extractor.PackedSize.ToString() + " bytes";
this.listBox1.Items.Clear();
foreach(string fileName in extractor.ArchiveFileNames){
this.listBox1.Items.Add(fileName);
&
补充:软件开发 , C# ,