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

    using ICSharpCode.SharpZipLib.Zip;
    using System;
    using System.Collections.Generic;
    using System.ComponentModel;
    using System.Data;
    using System.Drawing;
    using System.IO;
    using System.Linq;
    using System.Text;
    using System.Threading.Tasks;
    using System.Windows.Forms;

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

    private void button1_Click(object sender, EventArgs e)
    {
    //选择文件
    OpenFileDialog openFileDialog = new OpenFileDialog();
    openFileDialog.Multiselect = true;//选择多个文件
    string basePath = "";//路径
    //判断是否选中文件
    if (openFileDialog.ShowDialog() == DialogResult.OK)
    {
    basePath = Path.GetDirectoryName(openFileDialog.FileName);
    //创建压缩包集合
    using (ZipFile zip = ZipFile.Create(basePath + "压缩.zip"))
    {
    zip.BeginUpdate();//开始压缩
    foreach (string item in openFileDialog.FileNames)
    {
    zip.Add(item);
    }
    zip.CommitUpdate();//终止压缩
    }
    }
    MessageBox.Show("压缩成功!");

    }
    }
    }

  • 相关阅读:
    gvim : invalid input string
    端口
    Sequence Overview
    vi的使用
    Ubuntu安装CodeBlocks相关问题总结
    中断
    Ubuntu Software Repository
    UVA 12299 RMQ with Shifts
    UVA 12293 Box Game
    POJ 3468 A Simple Problem with Integers (1)
  • 原文地址:https://www.cnblogs.com/ryzryz/p/12159918.html
Copyright © 2011-2022 走看看