Click here to Skip to main content
15,441,508 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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:
VB
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?

VB
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
Updated 4-Dec-12 10: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

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[^].
 
Share this answer
 

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



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900