Код: Выделить всё
System.InvalidOperationException: 'File does not have a stream.'блестящий от примеров в их документации, вот простое приложение для консоли, которое должно было работать:
Код: Выделить всё
using SharpCompress.Archives;
using SharpCompress.Archives.SevenZip;
using SharpCompress.Common;
String srcFile = "Put the path to your *.7z file here";
String subPath = "Put the sub-path inside the archive you want to extract here";
String dstPath = "Put the path to want to extract to here";
using (SevenZipArchive archive = SevenZipArchive.Open(srcFile)) {
Console.Write($"Extracting {srcFile}... ");
foreach (SevenZipArchiveEntry entry in archive.Entries.Where(entry => !entry.IsDirectory)) {
String fileName = entry.Key.Replace(subPath, dstPath);
Console.WriteLine($" FROM: {entry.Key}");
Console.WriteLine($" TO: {fileName}");
Directory.CreateDirectory(Path.GetDirectoryName(fileName));
entry.WriteToFile(fileName, new ExtractionOptions() { //Exception Thrown Here
Overwrite = true
});
}
Console.WriteLine("DONE!");
}
Console.Write($"{Environment.NewLine}Press any key to continue...");
Console.ReadKey();
Подробнее здесь: https://stackoverflow.com/questions/794 ... rpcompress
Мобильная версия