Created
July 18, 2018 17:53
-
-
Save piksel/e4132290380d1744165e878a40d9c44f to your computer and use it in GitHub Desktop.
SharpZipLib v1.0.0-rc1 Chinese Filename Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<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> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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