如何多次解压缩同一个zip文件? [英] How to unzip the same zip file multiple times?

查看:542
本文介绍了如何多次解压缩同一个zip文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个zip提取器应用程序,如果我对该同一个zip文件解压缩多次,则应将其提取为myfile-1,myfile-2,myfile-3之类的东西。
示例:当我解压缩时,桌面上有sampleproject.zip,它应该像sampleproject,sampleproject-1,sampleproject-2。
任何建议。
提前谢谢!

I am developing a zip extractor app for which if i unzip multiple times the same zip file it should extract like myfile-1, myfile-2, myfile-3 something like this . example : there is sampleproject.zip in my desktop when i unzip it should be like sampleproject, sampleproject-1, sampleproject-2. Any Suggestions. Thanks in Advance!

推荐答案

根据您的评论,我建议您将文件解压缩到一个临时目录,然后将其内容移动到实际目录中,以进行处理这样做时,任何名称都会冲突。在大纲中:

Based on your comment I suggest you unzip your file to a temporary directory and then move its contents into the actual directory, handling any name clashes as you do that. In outline:


  1. 使用 URLForDirectory:inDomain:appropriateForURL:create:error: 创建一个适合解压缩的临时目录入。您应该为 appropriateForURL:参数传递 destinationPath 的URL;这应该给您一个与 destinationPath 相同卷的临时目录,从而使解压缩后的项目放置在正确的位置动作而不是 copies

  1. Use URLForDirectory:inDomain:appropriateForURL:create:error: to create a temporary directory suitable to unzip into. You should pass your the URL of your destinationPath for the appropriateForURL: parameter; this should give you a temporary directory on the same volume as destinationPath making placing the unzipped items into the right place moves rather than copies.

解压缩到(1)返回的临时目录中

Unzip into the temporary directory returned by (1)

如果在实现此算法时遇到问题,请提出一个新问题,请显示代码,解释您的问题,并包括指向该问题的链接,以便可以跟踪该线程。无疑,有人会帮助您进行下一步。

If you have problems implementing this algorithm ask a new question, show your code, explain your problem, and include a link back to this question so the thread can be followed. Someone will then undoubtedly help you with the next step.

HTH

这篇关于如何多次解压缩同一个zip文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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