Have you ever encountered a scenario when you have to download a few files zipped and compressed? Few developments involving the manipulation of documents and their management would require this. There are many packages out in the market. In this article, I will be sharing the use of the DotNetZip package to zip, unzip, and compress files using C#, VB.NET, and any .NET language.
Download the DotNetzip package from the NuGet package.
Download from here.
Once downloaded, it’s set to use the DotNetzip package to start zipping and compressing the files. For the files to be zipped, here I will be using the file path and selecting each to be zipped. Here, we will also see how a file is created on the fly (a PDF using Rotativa), saved in the same folder, and zipped.
The above code snippet generates a PDF using a CSS and HTML Razor View page using Rotativa and Rotativa. It is best to follow the mentioned article for more information on creating a PDF using Rotativa and MVC. Let’s look at the code snippet for zipping.
The above snippet is just required to start zipping and compressing the files. As you can see, using block for the ZipFile is created with instantiation of its object.
Then, the files present under the path are navigated using Server.MapPath(“”), Once the path is set, the files if with some unique string character in the filename needs to be searched and only zipped, is set to a variable.
Then each file is looped through and added to the ZipFile object, here zipFile.AddFiles(file, ZippedFolderName); ZipFolderName is the name you set for the folder with all the files after extraction.
There are three compression levels for the ZipFile an enum which is described through code below,
The above are the three algorithms used. I have used only BZip2 based on a few good reviews.
Once compressed and all files inserted into the folder, the zipped folder is ready to be downloaded using the FileStreamResult in MVC action.
This is the simple explanation and the code snippet for the Zip file concept. This is simple and handy to use and provides the compression algorithms that are good to go with.
Next recommended article Create Download and Open Zip File in PHP
Simple PHP function that can be used to create a ZIP file archive.
A journey has just begun to create a culture, not an organization.
We at INVINCIX are determined to digitize 500+ start-ups in this era of digitization during the course of the upcoming two fiscal years, FY 2022–2023 and FY 2024–2025.
Dealing directly with the definition and goal of the business.
Efficiency is something that requires constant study.
Deeper comprehension of one another's working methods that will pay off in the long run.
Our goal is to establish a GenInvinci organization with the capacity to "Engage," "Innovate," "Invent," and "Excel"
A sense of satisfaction when you touch the heart with emotion.
We will keep our feet grounded, to ensure, your head is in the cloud.
Honoring the exceptional INVINCIANS
A minute to reflect on the success
It means a lot to us.
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Join our Growing Team And Proud To Ba An INVINCIANS.
Let's connect and find the solutions you need. Our team is ready and waiting to assist you with any questions or concerns you may have.
The framework for digital transformation makes excellence in "Innovation," "Agility," and "Responsiveness" possible
The software industry began with the automation of manual tasks. Over time, the automation changed and became known as "Digitalization services"
Experience AD4P : Harness the power of IT to guarantee that your application is prepared for the future
Unique thoughts are valuable and creative thinking are hard to come by. A brilliant idea is always the source of a product
Our consulting will hold your hand and be part of you, through out transformation journey.
Clear emphasis on the experience not on the interface make us a class apart .
As enterprises look to software as a source of competitive advantage, they demand quality-at speed and scale.
Taking relevant info out of a data sea
A keen eye for the bottom line
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
Using barcodes to manage inventory quickly
Routing that is easy on the wallet while maintaining client satisfaction
Automating processes to increase efficiency in the service sector
Boost productivity and enable success with the vendor management system
Simplifying the verification and control of your inventory
Connecting world via blood
Implement the “Interpreted” “Inception”
We don’t inspect quality, we inject quality
UX is the key not the interface…
Transforming Database Innovation and Performance / Empowering Data-Driven Excellence
Digital transformation is a business discipline
“Swift and Simple” office automation
Simplify e-Invoicing with our secured SaaS-based APIs
Make your service station digital
Your digital event partner is here
Extracting meaningful data from ocean of data
connecting hospitality industry smoothly
A mini ERP for all your need
Connecting world via blood
Browse our workshop calendar for upcoming events and opportunities to expand your knowledge and skills.
Explore our diverse range of courses designed to cater to various interests, offering opportunities for personal and professional growth
Head Office
Sharadha Bhawan, Rajendra Nagar, Cuttack, Odisha - 753010, India
Branch Office
Plot No.353, 1st Floor, Infocity Ave, Sishu Vihar, Patia, Bhubaneswar, Odisha - 751024, India
Branch Office
60 eu tong sen street #02 03 furama city center Singapore 059804
Branch Office
Amba House, 15 College Road, Harrow, England, HA11BA
Branch Office
02nd Floor, Saigon Paragon Building, No.3 , Nguyen Luong Bang Street, Tan Phu Ward, District 07, Ho Chi Minh City, Vietnam