本文介绍了从.Jar中删除文件夹,同时将其视为邮政编码的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要从 .jar 文件中删除文件夹,但是要使用Sharpziplib将其视为 .zip 文件.有什么办法吗?

I need to delete a folder from a .jar file, but treating it as a .zip file with sharpziplib.Is there any way to do so?

我曾经尝试过使用Sharpziplib对 .jar 文件进行解压缩",然后将其删除并重新压缩,但无济于事-更不用说这样做的速度要慢得多.

I have tried before to "unzip" the .jar file using sharpziplib and then delete it and rezip it, but to no avail- not to mention it is much slower to do it that way.

如何直接删除文件夹?

How can I directly delete the folder?

推荐答案

但是,与普遍的看法相反,我不需要解压缩.jar文件.我只需要这样做(使用dotnetzip btw)-

Huh, contrary to popular belief, I didn't need to unzip the .jar file. I only needed to do this(Using dotnetzip btw)-

//Code to delete META-INF folder
using (ZipFile zip = ZipFile.Read(jarFile))
{
    List<string> files = zip.EntryFileNames.ToList<string>();
    List<string> delete = new List<string>();
    for (int i = 0; i < files.Count; i++)
    {
        if (files[i].Contains("META-INF"))
        {
            delete.Add(files[i]);
        }
    }
zip.RemoveEntries(delete);
zip.Save();
}
MessageBox.Show("Success!", "Success", MessageBoxButtons.OK, MessageBoxIcon.None);

这篇关于从.Jar中删除文件夹,同时将其视为邮政编码的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-30 12:55