开发者

Please explain set-content $zipfilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18)) line of Powershell Script

After investigating how to create a zip file with Powershell I found the following very helpful link which describes how to create a zip file using Powershell with the following line of script:

set-content $zipfilename ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18))
开发者_StackOverflow

This works like a charm, problem is I simply don't understand how it works. Could I please get a breakdown of what this does?


By using ("PK" + [char]5 + [char]6 + ("$([char]0)" * 18)) as the value to set-Content, we are simply adding the file header and creating a 0 byte .zip file.

To understand this, you may want to read under the section file headers:

  • Magic number (programming)
  • ZIP (file format)

Headers in ZIP files begin with "PK" (50 4B), the initials of Phil Katz, author of DOS compression utility PKZIP.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜