Extract .ZIP file with accent on name

6

I'm using the System.IO.Compression.ZipFile lib to unzip .zip files and I came across a major problem when trying to extract files that have accents in the name.

If I try to extract with UTF-8 encoding :

ZipFile.ExtractToDirectory(caminhoArquivoZip, "E:\localParaExtrair", Encoding.UTF8);

Files that have an accented name have the character instead of the accented letter.

If I pass another Encoding ( Unicode , for example), an exception is thrown:

  

The specified input name encoding is not supported.

If you try with Encoding.Default other strange character is in place of the accented letter.

Is this a library problem? Is there any way I can extract these files correctly?

I'm fully aware that you should not write file names with accents, but it's not me who creates the files.

    
asked by anonymous 21.07.2015 / 16:39

2 answers

6

With this Enconding it works:

ZipFile.ExtractToDirectory(caminhoArquivoZip, "E:\localParaExtrair", System.Text.Encoding.GetEncoding(850));
  

GetEncoding initializes a new instance of the Encoding class corresponding to the code page specified.

(Source: .Net Documentation >)

The code page 850 represents the encoding ibm850 - Eastern European (DOS)     

21.07.2015 / 18:42
0

The file name and / or folder name can not contain any special characters, such as accent. So how can folders have no? /% $ ......

Even if you try directly on windows explorer it will return the same error.

    
21.07.2015 / 16:42