Can I get a file inside a .zip file without unzipping the .zip file?

Using Files within a .zip file without having to unzip it

Page 1 of 1

1 Replies - 3622 Views - Last Post: 21 January 2010 - 01:07 PM Rate Topic: -----

#1 JennLynn39  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 5
  • Joined: 30-March 09

Can I get a file inside a .zip file without unzipping the .zip file?

Posted 21 January 2010 - 11:21 AM

I am trying to create an application that will copy files with a "*.1" extension over to another directory and change the file extension to .tif. The problem is that the *.1 files are located within zip files. Is it possible to copy files out of a zip file without having to extract it? The code I have so far is below. I have only gotten to the point to list all *.zip files found in a specific directory in a listbox. I am really looking to list all *.1 files found within all .zip files in a specific directory. Once they are all listed in the listbox, I will then chose a destination directory, copy them to the destination directory and change the files from a .1 extension to a .TIF extension.

Private Sub Button4_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button4.Click

		ListBox1.Items.Clear()

		FolderBrowserDialog1.SelectedPath = "C:\"
		FolderBrowserDialog1.Description = "Select A Directory"
		' Show the dialog and if the user chose OK, then the dialog will return a DialogResult of OK		
		' We can then set our textbox for the Path to the path they selected.		

		If FolderBrowserDialog1.ShowDialog() = Windows.Forms.DialogResult.OK Then
			TextBox1.Text = FolderBrowserDialog1.SelectedPath
		End If


		Dim files() As String

		files = Directory.GetFiles(TextBox1.Text, "*.zip")

		'Now we will loop through these files, adding ONLY the filename portion of the file found.		
		'Directory.GetFiles returns whole paths.		

		Dim file As String
		For Each file In files
			ListBox1.Items.Add(Path.GetFileName(file))
		Next

	End Sub



Is This A Good Question/Topic? 0
  • +

Replies To: Can I get a file inside a .zip file without unzipping the .zip file?

#2 snikmotnairb  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 13
  • View blog
  • Posts: 70
  • Joined: 02-May 08

Re: Can I get a file inside a .zip file without unzipping the .zip file?

Posted 21 January 2010 - 01:07 PM

I don't know that you can get at the files inside the Zipfile as it doesn't appear VB.net has anything like that built in, but this might help...

http://www.codeguru....ad.php?t=443029

Unzip the files to a temp directory, copy out all *.1 files, then clean up by deleting the temp directory.

Hope that helps...
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1