Zip and Unzip Using CodeGuru 
				DLL in VB.NET
				
 
					
						
						  
						 | 
						DigiOz Multimedia 
						April 24, 2006  | 
					
				
				Environment:  VB,.NET 2003
				The purpose of this short article is to show how to use the 
				Code Guru Zip/Unzip DLL, which was originally written for Visual 
				Basic 5 and 6, in a Visual Basic .NET Environment. If you are 
				interested in reading the original article by Chris Eastwood, 
				you can view it here: 
				
				
				
				http://www.codeguru.com/vb/gen/vb_graphics/fileformats/article.php/c6743/
				
				
				
				Step 1: First, you will need to download the DLL files 
				which were posted on Chris' Article. You can get a copy of them 
				at the end of this page. The zip file contains 3 DLL's: 
				
				CGZipLibrary.dll
				zip32.dll
				Unzip32.dll
				
				Simply download and extract the above 3 files into a directory 
				on your machine (make sure to remember where you are putting 
				them). 
				
					
						
						
							
								Step 2: Create 
								a new Visual Basic .NET Project by Launching 
								Visual Basic.NET, and selecting "Visul Basic 
								Projects". Click on the "Windows Application" 
								icon, and enter "ZipTutorial" as the Name of the 
								project. Accept the default "Location" for the 
								project that will be provided for you, and hit 
								"OK". Here is what it will look like: 
								 
								 
								  
								 
								Step 3: Copy and past the two DLL's 
								called "zip32.dll" and "Unzip32.dll" into the 
								"bin" folder of your new Project. Do NOT copy 
								over the "CGZipLibrary.dll" DLL over yet.  
								 
								 
								Step 4: A blank project will be opened 
								for you, with a default form called "Form1". On 
								the right side of the Visual Studio Screen, you 
								will have the "Solution Explorer". Expand and 
								Right Click on "References" folder, and Choose 
								"Add Reference". A new window will pop up.
								 | 
							 
						 
						 | 
					
				
				
					
						
						
							
								Step 5: Click 
								on the "Project" Tab, and hit the "Browse" 
								button. The "Select Component" window will 
								appear. Using the menu provided, navigate to the 
								location where you extracted the contents of the 
								first zip file, and find the "CGZipLibrary.dll" 
								DLL file. Here is what you will see: 
								 
								 
								  
								 
								Step 6: Select the "CGZipLibrary.dll" 
								file ONLY, hit OK to accept the selection, and 
								OK again to exit the "Add Reference" Screen. 
								Here is a screenshot of what you should now see 
								in your Solution Explorer, and inside the bin 
								directory of your project: 
								 
								 
								 
								 | 
							 
						 
						 | 
					
				
				
					
						
						
							
								Step 7: Double 
								Click on the empty Visual Basic Form, to get the 
								Form_Load Event in the code Section of the Form. 
								First, you will need to give your zip file a 
								name. Here is how you do that: 
 
									
										Dim zp As New 
										CGZipLibrary.CGZipFiles 
										zp.ZipFileName = "ZipTutorial.zip" 
  | 
									 
								 
								 
								The first line creates an instance of the 
								Library, and the second line will be the file 
								name for our zip file. By default, the 
								application will place the zip file inside the 
								bin directory of the project (since I did not 
								specify a path for the zip file to be placed 
								at). You can of course place a directory browse 
								dialog to allow your users to select a directory 
								on their system to place the zip file at.  
								 
								Step 8: Now we want to add some files to 
								our zip file. For the purpose of this article, I 
								have placed 3 images inside the bin directory of 
								the Visual Basic Project, in order to simplify 
								the code. Again, you can setup your own system 
								to have users select files from their machines 
								and add them to the zip file we are creating. 
								 
								Here is how to add new files to the zip archive: 
 
									
										zp.AddFile("cool.gif") 
										zp.AddFile("cry.gif") 
										zp.AddFile("evil.gif") 
  | 
									 
								 
								 
								Step 9: Finally, to actually initialize 
								the creation of the zip file (once you are done 
								adding all your files to the new zip archive), 
								you can do: 
 
									
										zp.MakeZipFile() 
										MessageBox.Show("Zip File Created at" & 
										vbCrLf & Application.StartupPath) 
  | 
									 
								 
								 
								Now run your project and you will see a Message 
								once the zip file is created for you. If you 
								open the "bin" folder of your project now, here 
								is what you will see inside it: 
								 
								  
								 
								The file "ZipTutorial.zip" will contain 3 image 
								files in it, if you open it and look inside it.
								 
								 
								That's it! Feel free to post any questions you 
								may have about this article either here at 
								CodeGuru, or on my website's Support Forum at
								www.digioz.com.
								 
								 
								Pete Soheil 
								DigiOz Multimedia 
								4/03/2006 | 
							 
						 
						 | 
					
				
				Downloads
				
				
				RequiredDLL.zip - RequiredDLL.zip
				
				
				ZipTutorialSource.zip - Project Source Code For Article