It’s easy with XCeed ZIP component

I was on a lookout for a good component which automatically extracts a ZIP file located on the server. Finally, I found Xceed ZIP for .NET, which performs the task with only few lines of code. I managed to unzip even a file with 5 MB in size very easily. I’m posting a tutorial with code snippet to illustrate how easy it is to unzip a ZIP file. Please note that you should ZIP the file using WINZIP.


You can easily extract the contents of a ZIP file on the server by following the steps given below.


Please note that in order to work with the example you should install XCeed ZIP for .NET which is available for download (45 days trial) from http://xceed.com/Zip_Net_Whatsnew.html


Step – 1


Copy the following DLL’s to the BIN directory of your website. If there is no such directory, then you can create it


Xceed.Compression.dll
Xceed.Compression.Formats.dll
Xceed.FileSystem.dll
Xceed.Zip.dll


You can locate these DLL files from Program Files\Xceed Components\Bin\.NET folder


Step – 2


Add the following code to the Page_Load() event


Try
Xceed.Zip.Licenser.LicenseKey = “ZINXX-XXXXX-XXXXX-XXXX”
Dim zip As New ZipArchive(New DiskFile(Server.MapPath(“.”) & “\Test.zip”))
Dim folder As New DiskFolder(Server.MapPath(“.”))
zip.CopyFilesTo(folder, True, True)
Response.Write(“Files Unzipped Successfully”)
Catch err As Exception
Response.Write(err.Message)
Finally
End Try


That’s it. Execute the file and you will see a message “Files Unzipped Successfully“. You should see a new folder named Test with the required file inside the root of your domain.


Please make sure to upload Test.Zip into the root directory before attempting to run the project


 

2 thoughts on “It’s easy with XCeed ZIP component”

Leave a Reply

Your email address will not be published. Required fields are marked *

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>