System.IO.Compression.ZipFile .NET 4.5 output zip in not suitable for Linux/Mac/Java

后端 未结 3 1443
清酒与你
清酒与你 2021-02-07 04:07

While using .NET System.IO.Compression.ZipFile.CreateFromDirectory class the outcome zip is badly extracted on system with forward-slash directory separator.

3条回答
  •  爱一瞬间的悲伤
    2021-02-07 04:33

    Microsoft has addressed this in .NET 4.6.1:

    Starting with apps that target the .NET Framework 4.6.1, the path separator used in the ZipArchiveEntry.FullName property has changed from the backslash ("\") used in previous versions of the .NET Framework to a forward slash ("/"). System.IO.Compression.ZipArchiveEntry objects are created by calling one of the overloads of the ZipFile.CreateFromDirectory method.

    Note:

    In addition, apps that target previous versions of the .NET Framework but are running on the .NET Framework 4.6.1 and later versions can opt in to this behavior by adding a configuration setting to the section of the application configuration file.

提交回复
热议问题