Click here to Skip to main content
12,076,727 members (45,816 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: VB VB.NET
I want to remove a folder (META-INF) from a .ZIP file, I have tried to do this before but failed. Does anyone have a code I can use to remove a folder?

I REALLY NEED HELP! I have until the 10th to release my program as planned, and I don't want to delay it again!

EDIT:
I have tried to search numerous times! Thats the problem. I found NO code that could help and I tried to do it on my own and got an error saying 'Entry does not exist'...

Here's a code:
Dim selection = zip1.SelectEntries("*.*", "META-INF")
For x = selection.Count - 1 To 0 Step -1
	Dim e As ZipEntry = selection(x)
	zip.RemoveEntry(e.FileName)
Next

EDIT 2:
Well now I have the code and no error comes up but It still does not delete it... Can anyone point out where I went wrong here?

Dim Threshold As New String("META-INF")
Using zip As ZipFile = ZipFile.Read("C:\Users\" + GetUserName + "\AppData\Roaming\MCqTools\Mod_p\editor.zip")
    Dim MarkedEntries As New System.Collections.Generic.List(Of ZipEntry)
    Dim e As ZipEntry
    For Each e In zip
        If (e.IsDirectory = Threshold) Then
            MarkedEntries.Add(e)
        End If
    Next
    Dim folderMETA As ZipEntry
    For Each zombie In MarkedEntries
        zip.RemoveEntry(folderMETA)
    Next
    zip.Save()
End Using
Posted 3-Dec-12 15:35pm
Edited 4-Dec-12 11:04am
v4
Comments
Expert Coming 4-Dec-12 0:21am
   
We don't just hand out source code on this site. If you wouldn't mind posting some code that shows what problems you are facing, what you have tried, and a more specific question people should be able to start helping.

1 solution

Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Based on the example "Read in a zip file, remove a few entries, save the file" from VB.NET Examples[^] you should be able do remove all files that have "META-INF" in the file name.

Use to ZipEntry[^] class to access the FileName[^].
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web01 | 2.8.160212.1 | Last Updated 4 Dec 2012
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100