• zip压缩解压缩 项目icsharpcode-SharpZipLib-e012155


    1. 大家可以到http://www.icsharpcode.net/opensource/sharpziplib/ 下载SharpZiplib的最新版本,支持Zip, GZip, BZip2 和Tar格式,本作者的项目代码如下

    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.Linq;
    using System.Text;
    using System.Windows.Forms;
    using ICSharpCode.SharpZipLib.Zip;//来自项目icsharpcode-SharpZipLib-e012155生成的ICSharpCode.SharpZipLib.dll

    namespace TestZIP
    {
    public partial class Form1 : Form
    {
    public Form1()
    {
    InitializeComponent();
    }

    private void button1_Click(object sender, EventArgs e)
    {
    try
    {
    using (FolderBrowserDialog dlg = new FolderBrowserDialog())
    {
    //dlg.CheckFileExists = true;
    //dlg.CheckPathExists = true;
    if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
    {
    if (dlg.SelectedPath != null)
    {
    FastZip fz = new FastZip();
    fz.CreateZip("123.zip", dlg.SelectedPath, true, "");
    MessageBox.Show("压缩完成!", "信息提示:", MessageBoxButtons.OK, MessageBoxIcon.Information);
    }
    }
    }
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.ToString());
    //throw;
    }
    }

    private void button2_Click(object sender, EventArgs e)
    {
    try
    {
    using (OpenFileDialog dlg = new OpenFileDialog())
    {
    //dlg.CheckFileExists = true;
    //dlg.CheckPathExists = true;
    if (dlg.ShowDialog(this) == System.Windows.Forms.DialogResult.OK)
    {
    if (dlg.FileName != null)
    {
    FastZip fz = new FastZip();
    fz.ExtractZip(dlg.FileName, Application.StartupPath + "\新建文件夹", "");
    //fz.CreateZip("123.zip", dlg.SelectedPath, true, "");
    MessageBox.Show("解压完成!", "信息提示:", MessageBoxButtons.OK, MessageBoxIcon.Information);
    }
    }
    }
    }
    catch (Exception ex)
    {
    MessageBox.Show(ex.ToString());
    //throw;
    }
    }
    }
    }

    项目

  • 相关阅读:
    10.11-10.16
    10.8-10.10
    9.26-28
    9.29css继承属性
    表单的学习
    排版
    css补充
    今天学的新内容
    新内容
    文本样式的修改
  • 原文地址:https://www.cnblogs.com/1175429393wljblog/p/5347316.html
Copyright © 2020-2023  润新知