简体   繁体   中英

Create an archive .zip from file stream where file mode is Read

There is a zip folder and it contains an XML file. This is been retried from a service as

return File.Open("location", FileMode.Open, FileAccess.Read, FileShare.Read)

Now in the UI, when the user clicks a link, he should get an archive .zip folder and this file should be available in that user's downloaded folder with the XML file.

Currently I am trying using ZipArchiveEntry.ExtractToFile() . It creates a zip folder but when I try to extract it manually, it says empty compressed folder.

Try with System.IO.Compression library and use ZipFile.ExtractToDirectory(zipPath, ExtractionPath) This might help.

For more help https://docs.microsoft.com/en-us/dotnet/standard/io/how-to-compress-and-extract-files

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM