none
System.IO.Compression.ZipFile RRS feed

  • Question

  • Hi Guys,

    I have question regarding one of our scripts. I am newbie so I hoop you can help me.

    I have a script that must zip a folder that has many sub folders and xml files. The script doing its job very well, but one of our customers that download this zip file on their linx machine and use a php script to unzip the files havin an issue. Customer says that files get unzip but with an error and they think we should add -fz- to our script. What I am not sure is that if  System.IO.Compression.ZipFile except any arguments.

    this is my script:

    If(Test-path "\\ntw001\Clients\Exports\my.zip") {Remove-item "\\ntw001\Clients\Exports\my.zip"}

    Add-Type -AssemblyName System.Text.Encoding
    Add-Type -AssemblyName System.IO.Compression.FileSystem

    class FixedEncoder : System.Text.UTF8Encoding {
        FixedEncoder() : base($true) { }

        [byte[]] GetBytes([string] $s)
        {
            $s = $s.Replace("\", "/");
            return ([System.Text.UTF8Encoding]$this).GetBytes($s);
        }
    }

    [System.IO.Compression.ZipFile]::CreateFromDirectory("C:\install\xml\artiste", "\\ntw001\Clients\Exports\my.zip", [System.IO.Compression.CompressionLevel]::Optimal, $false, [FixedEncoder]::new())


    Shahin

    Thursday, November 14, 2019 11:04 AM

All replies

  • No and the customer is wrong as they are likely using the wrong options to unzip.   What is "-fz-" anyway?  It is not an option on any zip utility that I have ever seen.   

    You shouldn't use the encoder.  Let the system choose the encoder for you. 

    Your issue is not really a scripting issue.


    \_(ツ)_/

    Thursday, November 14, 2019 11:25 AM
  • Thank you for your reply,

    customer has seeing this artical:

    unzip


    Shahin

    Thursday, November 14, 2019 11:28 AM
  • That is an issue with old Unix utilities. They will have to work at it on their end.

    To test your file use 7Zip. If it works then that is proof they are using an old Unix utility.


    \_(ツ)_/

    Thursday, November 14, 2019 11:36 AM
  • you are right, they are using an old version of Linux.


    Shahin

    Thursday, November 14, 2019 11:38 AM