将文件从.zip提取到.jar [英] Extract Files from .zip to .jar
本文介绍了将文件从.zip提取到.jar的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
您好我正在尝试将文件从.zip添加到.jar
这是我的代码:
Hello I'm trying to add the files from a .zip to a .jar
Here is my code:
namespace ConsoleApplication2
{
class Program
{
static void Main(string[] args)
{
string appdata = System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData);
string minecraft = System.IO.Path.Combine(appdata, ".minecraft");
string mc = System.IO.Path.Combine(bin, "minecraft.jar");
string destinationFile = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "toJar.zip");
using (ZipFile zip = ZipFile.Read(destinationFile))
zip.ExtractAll(mc, ExtractExistingFileAction.OverwriteSilently);
}
}
}
问题是当我执行项目是无法创建C:\ Users\Rafael \ AppData \Roaming\.minecraft\bin\minecraft.jar因为有一个同名的文件或目录。 />
我正在使用Ionic Zip
谢谢
The problem is that when I execute the project is says "Can not create "C:\ Users\Rafael\ AppData\Roaming\.minecraft\bin\minecraft.jar" because there is a file or directory with the same name."
I'm using Ionic Zip
Thanks
推荐答案
Jar是一种类似winzip的存档格式。它不是可以只复制文件的物理文件夹。您需要从zip存档中提取文件,并以某种方式以编程方式将它们添加到您的jar存档文件中。
这里有一些可能有用的链接:
http: //stackoverflow.com/questions/14465230/extract-files-from-a-zip-into-a-jar-archive [ ^ ]
用C#打开罐子 [ ^ ]
< a href =http://www.dzone.com/snippets/adding-files-existing-jar-file> http://www.dzone.com/snippets/adding-files-existing-jar-file [ ^ ]
祝你好运!
Jar is an archive format sort of like winzip. It is not a physical folder you can just copy files to. You need to extract the files from your zip archive and somehow programmatically add them to your jar archive file.
Here's a few links that might be helpful:
http://stackoverflow.com/questions/14465230/extract-files-from-a-zip-into-a-jar-archive[^]
Opening Jars with C#[^]
http://www.dzone.com/snippets/adding-files-existing-jar-file[^]
Good luck!
这篇关于将文件从.zip提取到.jar的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文