简体   繁体   English

根据其他zip文件C#更新zip文件

[英]Update zip file based on other zip file C#

So i have a zip file in a directory. 所以我在目录中有一个zip文件。 This zip file contains different kind of files. 该zip文件包含其他类型的文件。 When a user clicks on a button in my WPF application, the zip file needs to be updated. 当用户单击WPF应用程序中的按钮时,需要更新zip文件。

It needs to check files from another zip file in another directory. 它需要检查另一个目录中另一个zip文件中的文件。 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. 如果一个文件在第一个zip文件中不存在,则需要将该文件从另一个zip文件复制到新的zip文件中。

i used the Ionic zip methode for this. 我为此使用了离子拉链方法。

So far i just used the file.copy overwrite = true code. 到目前为止,我只使用了file.copy overwrite = true代码。 But when the zip file is 1gb+ it is taking very long because it just replaced the zip file. 但是,当zip文件的大小为1gb +时,它将花费很长时间,因为它只是替换了zip文件。

does someone know how i can resolve this? 有人知道我该如何解决吗?

Greetings Thomas 托马斯的问候

UPDATE: 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);

        }

You can use the DotNetZip library. 您可以使用DotNetZip库。

Check the file in the zip : 检查zip文件:

zip["Readme.txt"] = null;

But anyway you must compress files again for changing zips password. 但是无论如何,您都必须再次压缩文件以更改zip密码。 You can find examples for that here . 您可以在此处找到示例。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM