Code: Select all
System.InvalidOperationException: 'File does not have a stream.'
Gläubig aus Beispielen in ihrer Dokumentation. Hier finden Sie eine einfache Konsolenanwendung, von der erwartet wurde PrettyPrint-Override ">
Code: Select all
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();
< /code>
Hat jemand einen Einblick, warum diese Ausnahme ausgelöst wird und oder wie man einen Untersolder aus einem 7-Zip-Archiv richtig extrahiert? < /p>
P.S. Bitte beachten Sie, dass dies kein [url=viewtopic.php?t=11587]Problem[/url] ist, wenn das 7-Zip-Archiv getestet wird, da der folgende Code es extrahiert: < /p>
Directory.CreateDirectory(dstPath);
using (SevenZipArchive archive = SevenZipArchive.Open(srcFile)) {
archive.ExtractToDirectory(dstPath);
}