Creating a zipped/compressed folder in Windows using Powershell or the command line

后端 未结 6 1395
野性不改
野性不改 2020-12-13 04:56

I am creating a nightly database schema file and would like to put all the files created each night, one for each database, into a folder and compress that folder. I have a

6条回答
  •  清歌不尽
    2020-12-13 05:52

    A native way with latest .NET 4.5 framework, but entirely feature-less:

    Creation:

    Add-Type -Assembly "System.IO.Compression.FileSystem" ;
    [System.IO.Compression.ZipFile]::CreateFromDirectory("c:\your\directory\to\compress", "yourfile.zip") ;
    

    Extraction:

    Add-Type -Assembly "System.IO.Compression.FileSystem" ;
    [System.IO.Compression.ZipFile]::ExtractToDirectory("yourfile.zip", "c:\your\destination") ;
    

    As mentioned, totally feature-less, so don't expect an overwrite flag.

提交回复
热议问题