tar压缩包解压文件中文名出现乱码解决方法

using (Stream stream = File.OpenRead(tarPath))
                {
                    ReaderOptions o = new ReaderOptions();
                    var oo = new ArchiveEncoding();
                    oo.Default = Encoding.Default;// System.Text.Encoding.UTF8;
                    o.ArchiveEncoding = oo;
                    var reader = ReaderFactory.Open(stream, o);
                    while (reader.MoveToNextEntry())
                    {
                        if (!reader.Entry.IsDirectory)
                        {
                            fileListName.Add(reader.Entry.Key);
                            var op = new ExtractionOptions();
                            op.Overwrite = true;
                            reader.WriteEntryToDirectory("C:\\", op);
                        }
                    }
                }

直接贴主要代码,防止伸手党

猜你喜欢

转载自www.cnblogs.com/victor-huang/p/9267387.html