System.IO.Compression.ZipFile .NET 4.5 output zip in not suitable for Linux/Mac/Java
.net, zip
Solution
To overcome this problem a workaround exists:
class MyEncoder : UTF8Encoding
{
public MyEncoder()
{
}
public override byte[] GetBytes(string s)
{
s = s.Replace("\\", "/");
return base.GetBytes(s);
}
}
System.IO.Compression.ZipFile.CreateFromDirectory("C:/ABC", "C:/tmp/ABC.zip", CompressionLevel.Fastest, false, new MyEncoder());
Problem
While using .NET System.IO.Compression.ZipFile.CreateFromDirectory class the outcome zip is badly extracted on system with forward-slash directory separator. Reason: The zip contains backslash inside the names