0

I have this unzipping function which is is using a .NET library (compression), but the problem is I am having some unicode problems in the file name for example "µ" is being converted to "æ"

is there a solution to this problem without using other unzipping libraries because I am limited to some licenses and found this one suite me the best

 using System.IO.Compression;

 private void Unzip()
    {
        try
        {
            string appPath = Path.GetDirectoryName(Application.ExecutablePath);

            // unzip update
            using (ZipArchive archive = System.IO.Compression.ZipFile.OpenRead(ZipFile))
            {

                foreach (ZipArchiveEntry entry in archive.Entries)
                {
                    string fullPath = Path.Combine(appPath, entry.FullName);
                    if (String.IsNullOrEmpty(entry.Name))
                    {
                        Directory.CreateDirectory(fullPath);
                    }
                    else
                    {
                        if (!entry.Name.Equals("Updater.exe"))
                        {
                            entry.ExtractToFile(fullPath,true);

                        }
                    }
                }

                //  UpdateProgress(((float)s.Position / (float)fileStream.Length) * 100F);
                //System.Threading.Thread.Sleep(extraWaitMilliseconds); //don't go too fast

            }
            UnzipFinished();  //*********^

        }            
        catch (Exception ex)
        {
        UnzipFailed(ex);
        }
    }
eMizo
  • 269
  • 1
  • 6
  • 16
  • I love how you say "this one suits you the best" even though it clearly doesn't suit you that good (and hence the question here). – R. Martinho Fernandes Nov 14 '13 at 13:19
  • I love how you interpreted it your way.. it suits me the best when it comes to the licensing issue that I am limited to. – eMizo Nov 14 '13 at 13:25
  • Note that the accepted answer from GvS is not quite correct. It works in the specific case where the zip file uses cp850. If it using a different encoding, you will have to specify that instead. See Adriano's answer for background information. But based on your example, cp850 may be the right choice in your case. – oefe Nov 16 '13 at 17:05

1 Answers1

0

I read your restriction about the license, but I think, you will find this article on codeproject useful.

It explains how to use windows internal ZIP with a dot net wrapper, and the discussion thread in this link helped me with special characters in file/direcory names.

Link "C# Use Zip Archives without External Libraries" Using the title as google search items brings me the article on top position. Basically its a wrapper about the MS.Internal.IO.Zip.

nabuchodonossor
  • 2,095
  • 20
  • 18