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

时间:2018-07-05 11:43:30   收藏:0   阅读:1074
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);
                        }
                    }
                }

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

原文:https://www.cnblogs.com/victor-huang/p/9267387.html

评论(0
© 2014 bubuko.com 版权所有 - 联系我们:wmxa8@hotmail.com
打开技术之扣,分享程序人生!