更新基于其他zip文件的zip文件C# [英] Update zip file based on other zip file C#

查看:71
本文介绍了更新基于其他zip文件的zip文件C#的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

所以我在目录中有一个zip文件。此zip文件包含不同类型的文件。当用户点击我的WPF应用程序中的按钮时,需要更新zip文件。



它需要检查另一个目录中另一个zip文件中的文件。如果文件在第一个zip文件中不存在,则需要将该文件从另一个zip文件复制到新的zip文件。



i使用Ionic zip方法这个。



到目前为止,我只使用了file.copy overwrite = true代码。但是当zip文件是1gb +它需要很长时间,因为它只是替换了zip文件。



有人知道我怎么解决这个问题吗?



问候托马斯



我的尝试:



这是我到目前为止的代码:



private void getlocaldata()

{



string admindata = @\\\\
etworklocation\test.zip;

string localPath = @C:\ finaldata\test.zip;



File.Copy(admindata,localPath,true);



}

解决方案

基本上,它只是意味着从头开始重新打包文件。您解压缩这两个文件,根据您制定的标准确定应该进入目标ZIP文件的内容,从头开始创建一个新的ZIP文件。也许在最后你可能想要将生成的文件重命名为旧文件,有效地丢失了你不再需要的旧文件。



-SA

So i have a zip file in a directory. This zip file contains different kind of files. When a user clicks on a button in my WPF application, the zip file needs to be updated.

It needs to check files from another zip file in another directory. If a file doesnt excist in the first zip file, it needs to copy that file from the other zip file to the new zip file.

i used the Ionic zip methode for this.

So far i just used the file.copy overwrite = true code. But when the zip file is 1gb+ it is taking very long because it just replaced the zip file.

does someone know how i can resolve this?

Greetings Thomas

What I have tried:

this is the code i got so far:

private void getlocaldata()
{

string admindata = @"\\networklocation\test.zip";
string localPath = @"C:\finaldata\test.zip";

File.Copy(admindata, localPath, true);

}

解决方案

Basically, it simply means re-packing the file from scratch. You unpack both files, decide what should go into the target ZIP file according the criteria you formulated, create a new ZIP file from scratch. Perhaps at the end you may want to rename that resulting file to you old file, effectively losing your old file which you don't need any longer.

—SA


这篇关于更新基于其他zip文件的zip文件C#的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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