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); } } } }