删除ZIP Dotnetzip中的文件夹 [英] Remove Folder in ZIP Dotnetzip

查看:99
本文介绍了删除ZIP Dotnetzip中的文件夹的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想从.ZIP文件中删除文件夹(META-INF),我之前尝试过这样做但是失败了。有没有人有我可以用来删除文件夹的代码?



我真的需要帮助!我要到10日才按计划发布我的节目,我不想再拖延它了!



编辑:

我试过多次搜索!那就是问题所在。我发现没有任何代码可以提供帮助,我试图自己做,并得到一个错误说''条目不存在''...



这里' 'sa code =

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!


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





编辑2:

现在好了我的代码并且没有出现错误但它仍然没有删除它...任何人都可以指出我在哪里出错了吗?





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

推荐答案

基于示例读入zip文件,删除一些条目,保存文件来自 VB.NET示例 [ ^ ]你应该能够删除文件名中包含META-INF的所有文件。



用于ZipEntry [ ^ ]类访问文件名 [ ^ ]。
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[^].


这篇关于删除ZIP Dotnetzip中的文件夹的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆