54 lines
1.5 KiB
C#
54 lines
1.5 KiB
C#
using System;
|
|
using System.Collections.Generic;
|
|
using System.ComponentModel;
|
|
using System.Data;
|
|
using System.Drawing;
|
|
using System.IO;
|
|
using System.IO.Compression;
|
|
using System.Linq;
|
|
using System.Text;
|
|
using System.Threading.Tasks;
|
|
using System.Windows.Forms;
|
|
|
|
namespace Publish
|
|
{
|
|
public partial class Form1 : Form
|
|
{
|
|
public Form1()
|
|
{
|
|
InitializeComponent();
|
|
}
|
|
|
|
private void btnPack_Click(object sender, EventArgs e)
|
|
{
|
|
try
|
|
{
|
|
List<string> filePathLst = new List<string>();
|
|
string destinationZip = AppDomain.CurrentDomain.SetupInformation.ApplicationBase + "Update.zip";
|
|
foreach (var item in this.lstFile.Items)
|
|
{
|
|
filePathLst.Add(AppDomain.CurrentDomain.SetupInformation.ApplicationBase + item.ToString());
|
|
}
|
|
using (ZipArchive zip = ZipFile.Open(destinationZip, ZipArchiveMode.Create))
|
|
{
|
|
foreach (string filePath in filePathLst)
|
|
{
|
|
zip.CreateEntryFromFile(filePath, Path.GetFileName(filePath), CompressionLevel.Optimal);
|
|
}
|
|
}
|
|
MessageBox.Show("打包成功!");
|
|
this.Close();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
MessageBox.Show(ex.Message);
|
|
}
|
|
}
|
|
|
|
private void btnSelect_Click(object sender, EventArgs e)
|
|
{
|
|
|
|
}
|
|
}
|
|
}
|