Skip to content

Instantly share code, notes, and snippets.

@piksel
Created July 18, 2018 17:53
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save piksel/e4132290380d1744165e878a40d9c44f to your computer and use it in GitHub Desktop.
Save piksel/e4132290380d1744165e878a40d9c44f to your computer and use it in GitHub Desktop.
SharpZipLib v1.0.0-rc1 Chinese Filename Test
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2.1</TargetFramework>
<RootNamespace>chinese_test</RootNamespace>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="SharpZipLib" Version="1.0.0-rc1" />
</ItemGroup>
</Project>
using System;
using System.IO;
using ICSharpCode.SharpZipLib.Zip;
namespace chinese_test
{
class Program
{
static void Main(string[] args)
{
var testZip = "test.zip";
var testDir = "testFiles";
Directory.CreateDirectory(testDir);
var testFile = Path.Combine(testDir, "測試.txt");
var client = new System.Net.Http.HttpClient();
Console.WriteLine("Downloading test file...");
using(var dlStream = client.GetStreamAsync("https://github.com/icsharpcode/SharpZipLib/files/2197070/default.txt").Result)
using(var fs = File.Create(testFile))
{
dlStream.CopyTo(fs);
}
var zipper = new FastZip
{
EntryFactory = new ZipEntryFactory
{
IsUnicodeText = true
}
};
Console.WriteLine("Zipping test dir...");
zipper.CreateZip(testZip, testDir, true, null, null);
Console.WriteLine("Listing zip entries:");
using(var zipFile = new ZipFile(testZip))
{
foreach(ZipEntry entry in zipFile)
{
Console.WriteLine($" Entry: {entry.Name}");
}
}
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment