C#支持格式最多的解压缩开源库SharpCompress


string archivePath = "path/to/";
string extractPath = "path/to/extract/folder";
string[] filesRar = Directory.GetFiles(archivePath, "*.RAR");
            foreach (var item in filesRar)
            {
                using (Stream stream = File.OpenRead(item))
                {
                    var reader = SharpCompress.Readers.ReaderFactory.Open(stream);
                    while (reader.MoveToNextEntry())
                    {
                        if (!reader.Entry.IsDirectory)
                        {
                            reader.WriteEntryToDirectory(extractPath);
                        }
                    }
                }
            }

 

posted @ 2023-05-16 17:50  LuoCore  阅读(297)  评论(0编辑  收藏  举报