0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

C#でZipファイルの作成を行う

Last updated at Posted at 2022-02-22

想定環境:Visual Studio 2019

ソリューションエクスプローラーを右クリックし,NuGetパッケージの管理から参照で検索欄に"C1.C1Zip"と検索
インストール

C1.C1Zipをインストールする

var zip = new C1.C1Zip.C1ZipFile();//C1ZipFileクラスのインスタンス化
string path="";//zipファイルを置きたい場所の指定 例:C:\Users\ユーザ名\Desktop\
zip.create(path+@"\main.zip")//@はエスケープシーケンス 
//main.zip ←好きな名前に変更
zip.password="";//パスワードの指定
zip.Entries.Add(filename)//filenameは圧縮したいファイル 例:テキストファイルやWordファイルなど

これで圧縮ファイルの作成が可能!!

追記

C#はオブジェクトの型推論?(var)が使えるから,インスタンス化するときにvarを使うとタイピングが短くてすむね

0
1
1

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?