Получение исключения "Файл содержит поврежденные данные" при открытии пакета XPSDocument
Я получаю исключение в моем консольном приложении
HResult -2146233033 InnerException null
Message File contains corrupted data.
Source WindowsBase SourceUri null StackTrace at MS.Internal.IO.Zip.ZipIOEndOfCentralDirectoryBlock.FindPosition(Stream archiveStream) at MS.Internal.IO.Zip.ZipIOEndOfCentralDirectoryBlock.SeekableLoad(ZipIOBlockManager blockManager) at MS.Internal.IO.Zip.ZipArchive..ctor(Stream archiveStream, FileMode mode, FileAccess access, Boolean streaming, Boolean ownStream) at MS.Internal.IO.Zip.ZipArchive.OpenOnStream(Stream stream, FileMode mode, FileAccess access, Boolean streaming) at System.IO.Packaging.ZipPackage..ctor(Stream s, FileMode mode, FileAccess access, Boolean streaming) at System.IO.Packaging.Package.Open(Stream stream, FileMode packageMode, FileAccess packageAccess, Boolean streaming)
Пробовал это смотреть в ответах, но это не помогло.
string xpsfilename = @"D:\test\sample_file.xps";
var webClient = new System.Net.WebClient();
var data = webClient.DownloadData(xpsfilename);
//var data = File.ReadAllBytes(xpsfilename);
using (MemoryStream stream = new System.IO.MemoryStream(data))
{
var package = System.IO.Packaging.Package.Open(stream); /* Exception thrown here */
var xpsDocument = new System.Windows.Xps.Packaging.XpsDocument(package, System.IO.Packaging.CompressionOption.SuperFast, xpsfilename);
var sequence = xpsDocument.GetFixedDocumentSequence();
SaveDocumentPagesToImages(sequence, @"D:\test");
}