主要是利用开源dll----SharpCompress.dll
1 using (Stream stream = File.OpenRead(exePath + @"\Update.RAR")) 2 { 3 var reader = ReaderFactory.Open(stream); 4 while (reader.MoveToNextEntry()) 5 { 6 if (!reader.Entry.IsDirectory) 7 { 8 //Console.WriteLine(reader.Entry.FilePath); 9 reader.WriteEntryToDirectory(exePath, ExtractOptions.ExtractFullPath | ExtractOptions.Overwrite); 10 } 11 } 12 }