zoukankan      html  css  js  c++  java
  • 文件压缩

    1、示例图(WinForm窗体应用程序)

    2、首先下载SharpZipLib插件

    3、代码

    public partial class Form1 : Form
        {
            public Form1()
            {
                InitializeComponent();
            }
            //选择文件1
            private void button1_Click(object sender, EventArgs e)
            {
                DialogResult dia = openFileDialog1.ShowDialog();
                if (dia == DialogResult.OK)
                {
                    txtFile1.Text = openFileDialog1.FileName;
                }
            }
            //选择文件2
            private void button2_Click(object sender, EventArgs e)
            {
                DialogResult dia = openFileDialog1.ShowDialog();
                if (dia == DialogResult.OK)
                {
                    txtFile2.Text = openFileDialog1.FileName;
                }
            }
            //压缩位置
            private void button3_Click(object sender, EventArgs e)
            {
                DialogResult dia = saveFileDialog1.ShowDialog();
                if (dia == DialogResult.OK)
                {
                    txtWei.Text = saveFileDialog1.FileName;
                }
            }
            //开始压缩
            private void button4_Click(object sender, EventArgs e)
            {
                string path = txtWei.Text;
                ZipFile zip = ZipFile.Create(path);
                zip.BeginUpdate();
                zip.Add(txtFile1.Text);
                zip.Add(txtFile2.Text);
                zip.Password = txtPwd.Text;//密码
                zip.SetComment(txtDes.Text);//备注
                zip.CommitUpdate();
                MessageBox.Show("压缩完成");
            }
        }
  • 相关阅读:
    Go语言通道(chan)——goroutine之间通信的管道
    GO语言数组,切片,MAP总结
    GO数组
    GO切片
    GO语言测试
    GO语言html模板
    Go语言中defer语句使用小结
    微信小程序 某个页面直接返回首页
    小程序常用变量
    bzoj1030
  • 原文地址:https://www.cnblogs.com/dujian123/p/10582728.html
Copyright © 2011-2022 走看看