Create a ZIP using streams and the ZipArchive class #įor this demo, I have downloaded all the. You can find all the source code on this GitHub Repository. But first, let's learn how to create the ZIP archive. In this blog post, you'll learn how to do just that from an ASP.NET (Core) MVC Action, a Razor Page, and a simple endpoint. Using ZipArchive you can create a ZIP file on the fly and send it to the client from ASP.NET without having to save the ZIP file to disk. The latter is more complicated to use but provides more flexibility because you can accept any stream to read from or write to whether the data comes from disk, from an HTTP request, or from a complicated data pipeline. On the other hand, the ZipArchive class uses streams to read and write ZIP files. ZipFile is a great API for simple use-cases where the source and target are both on disk. The ZipFile class has static methods to create and extract ZIP files without dealing with streams and byte-arrays. NET has multiple built-in APIs to create ZIP files. If you're trying to generate ZIPs and send them to the browser using ASP.NET MVC Framework, check out " Create ZIP files on HTTP request without intermediate files using ASP.NET MVC Framework".
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |