概要
cscの作法、調べてみた。
sevenzipsharp.dll使ってみた。
圧縮してみた。
参考にしたページ
コンパイル手順
- sevenzipsharp.dll(0.64)をダウンロード。
- 7z.dllをダウンロード。
- コンパイル
>csc 7z0.cs /platform:x86 /reference:sevenzipsharp.dll
サンプルコード
using System;
using System.Windows.Forms;
using System.Drawing;
using SevenZip;
namespace seven
{
public class Form1 : Form {
public Button button1;
public Form1() {
Text = "7z";
button1 = new Button();
button1.Location = new System.Drawing.Point(50, 50);
button1.Size = new System.Drawing.Size(100, 30);
button1.Text = "test";
Controls.Add(button1);
button1.Click += new EventHandler(button1_Click);
}
private void button1_Click(object sender, EventArgs e) {
SevenZipBase.SetLibraryPath("7z.dll");
SevenZipCompressor compressor = new SevenZipCompressor();
compressor.CompressDirectory(Environment.CurrentDirectory + "\\archive", "archive.7z");
}
[STAThread]
static void Main() {
Application.Run(new Form1());
}
}
}
以上。