Powershell版(ZipFileクラス利用サンプル) .zip ファイルを作成して抽出

Tech

 C#版『ZipFile クラスを使用して圧縮された .zip ファイルの作成と抽出を行う方法』をPowershell版にしたもの。この例では、フォルダーの内容を新しい .zip ファイルに圧縮し、その zip を新しいフォルダーに抽出します。サンプルを実行するには、プログラムのフォルダーに start フォルダーを作成し、圧縮するファイルをそこに置きます。

サンプル

引用元

ZipFile.ExtractToDirectory メソッド (System.IO.Compression) | Microsoft Docs

元にしたコード(C#版)

using System;
using System.IO.Compression;

class Program
{
    static void Main(string[] args)
    {
        string startPath = @".\start";
        string zipPath = @".\result.zip";
        string extractPath = @".\extract";

        ZipFile.CreateFromDirectory(startPath, zipPath);

        ZipFile.ExtractToDirectory(zipPath, extractPath);
    }
}
ライセンス:本記事のテキスト/コードは特記なき限り CC BY 4.0 です。引用の際は出典URL(本ページ)を明記してください。
利用ポリシー もご参照ください。

コメント

タイトルとURLをコピーしました