I am trying to get this Powershell code to work:
Add-Type -Path 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.IO.Compression.FileSystem.dll'
$startPath = "D:\nade\CBA\Zip\StartPath"
$zipPath = "D:\nade\CBA\Zip\result.zip"
$extractPath = "D:\nade\CBA\Zip\Extract"
[System.IO.Compression.FileSystem.ZipFile]::CreateFromDirectory($startPath, $zipPath)
[System.IO.Compression.FileSystem.ZipFile]::ExtractToDirectory($zipPath, $extractPath)
However I get the following error:
Unable to find type [System.IO.Compression.FileSystem.ZipFile]. Make sure that the assembly that contains this type is loaded.
I have tried using the other DLL located here:
C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.IO.Compression.FileSystem.dll
However I still get the same error.
How can I correctly import this library?
EDIT: I have tried all of the following, none of them worked:
[System.Reflection.Assembly]::LoadWithPartialName("System.IO.Compression.FileSystem")
Add-Type -Path 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5.1\System.IO.Compression.FileSystem.dll'
Add-Type -Path 'C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETFramework\v4.5\System.IO.Compression.FileSystem.dll'
Add-type -AssemblyName "System.IO.Compression.FileSystem"