English 中文(简体)
如何从 Windows 上 C # 的 MACOS 中提取 ZIP 档案
原标题:How to extract ZIP archives from MACOS with C# on Windows
  • 时间:2012-05-25 12:06:58
  •  标签:
  • c#
  • macos
  • zip

在 Windows 服务器2008 R2 上运行的 C# 我的应用程序中, 我需要能够提取任何在 Windows 或 MAC OSX 上创建的 ZIP 文件。 目前我使用 < a href=" http://dotnetzip.codeplex.com/" rel= "no follown noreferrerr" > DotNetZip 库 。

但此库无法提取在文件名中带有特殊字元的 MACOSX ZIP 档案。 我尝试在编码中指定不同的编码, 包括 < strong> > macintosh 。 GetEncoding( 字符串) 方法 。

Windows 内置的拉链工具也干扰了特殊人物。 WinRAR 3.x 也有。 但是 WinRAR 4.x 似乎是唯一能正确工作的工具 。

是否可以从任何C#ZIP图书馆提取这样的ZIP档案?

更新: 这是在 Mac OSX 中以默认 Zip 函数创建的 zip 归档 。 第一个屏幕拍摄显示 Windows Zip 函数如何无法解码文件名。 第二个屏幕拍摄显示 WinRAR 4. 11 打开的归档 :

Archive opened with Windows 7 Zip Archive opened with WinRAR 4.11

下载 < a href=>"https://www.droppox.com/s/4dz23xp3wbt3e4y/Arkiv.zip" rel=“不跟随无悔者”>Sample ZIP档案 来自Mac OSX的档案

问题回答

Did you checkout SevenZipSharp... It uses 7-Zip dll to extract archives and IMO, 7-zip is the best archive handler..

Update :

我在挖掘示例拉链和

二进制中提供 DotNetZip ,您可以看到在 DropDownBox 中所有可能的编码。

包括UTF-8、Zip Daude(IBM437)、UTF-32、Unicode等。

我得到了UTF -8编码的最好结果... 和WinRAR一样读...

此外,海事组织只有WinRAR在所有档案中使用UTF-8,而其他Zip工具,如7-Zip,Explorer Daude Zip Viewer则使用Zip默认编码,使得他们能错误阅读文件名!

所以最好的选择是坚持 并使用这样的代码 :

using (ZipFile zf = new ZipFile(Application.StartupPath + "\Arkiv.zip", new UTF8Encoding()))
{
    zf.ExtractAll(Application.StartupPath + "\Arkiv\");
}

This code is tested to be working by me! Note that, after you extract the filenames will be shown in UTF8 formatting in the Explorer but if you open the zip file directly, explorer uses Zip Default Encoding.

Image Showing the DotNetZip Tool in UTF-8 encoding : Image

Update 2 :

文本的自动检测 Encoding {code> < this SO Question 和 < a href="http://www.codeproject.com/ artes/17201/ conserve-Encoding-for-In-Outo-Text" rel="nofolpoln norefrer"\code > > < thiscode-Project 条 和 < a href="http://code.gogle.com/p/ud/"rel="nofol noreferr"\\code>>>>UDE -C# Mozilla 通用查塞检测器的港口





相关问题
Anyone feel like passing it forward?

I m the only developer in my company, and am getting along well as an autodidact, but I know I m missing out on the education one gets from working with and having code reviewed by more senior devs. ...

NSArray s, Primitive types and Boxing Oh My!

I m pretty new to the Objective-C world and I have a long history with .net/C# so naturally I m inclined to use my C# wits. Now here s the question: I feel really inclined to create some type of ...

C# Marshal / Pinvoke CBitmap?

I cannot figure out how to marshal a C++ CBitmap to a C# Bitmap or Image class. My import looks like this: [DllImport(@"test.dll", CharSet = CharSet.Unicode)] public static extern IntPtr ...

How to Use Ghostscript DLL to convert PDF to PDF/A

How to user GhostScript DLL to convert PDF to PDF/A. I know I kind of have to call the exported function of gsdll32.dll whose name is gsapi_init_with_args, but how do i pass the right arguments? BTW, ...

Linqy no matchy

Maybe it s something I m doing wrong. I m just learning Linq because I m bored. And so far so good. I made a little program and it basically just outputs all matches (foreach) into a label control. ...

热门标签