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

    准备工作:
    在程序包管理器控制台安装 Install-Package SharpZipLib
    引用 using ICSharpCode.SharpZipLib.Zip;

    页面:

     

    代码如下:

       //打开要压缩的文件
       private void button1_Click(object sender, EventArgs e)
        {
          //打开文件
            OpenFileDialog openFile = new OpenFileDialog();
            if (openFile.ShowDialog()==DialogResult.OK)
            {
                textBox1.Text = openFile.FileName;
            }
        }
        //选择压缩后保存的路径
        private void button2_Click(object sender, EventArgs e)
        {
            FolderBrowserDialog openFile2 = new FolderBrowserDialog();
            if (openFile2.ShowDialog()==DialogResult.OK)
            {
                textBox2.Text = openFile2.SelectedPath+@"	ext.Zip";
            }
        }
       //确认压缩
        private void button3_Click(object sender, EventArgs e)
        {
            //测试保存的路径是否正确
            MessageBox.Show(textBox2.Text);
            using (ZipFile zip = ZipFile.Create(textBox2.Text))
            {
                zip.BeginUpdate();
                zip.Add(textBox1.Text);
                zip.CommitUpdate();
            }
        }
  • 相关阅读:
    CalcIntegerLength
    ReadIniTest_GetPrivateProfileString
    map test
    逻辑判断
    AppDomain.Unload_MarshalByRefObject
    网络编程
    pymysql
    MySQL多表查询
    MySQL单表查询
    python3 中引用 HTMLTestRunner.py 模块的注意事项
  • 原文地址:https://www.cnblogs.com/lhl123/p/10636526.html
Copyright © 2011-2022 走看看