在Cordova中解压缩文件和文件夹

时间:2018-04-19 10:19:51

标签: cordova ionic-framework zip cordova-plugins unzip

我目前正在开发Cordova应用。我试图解压缩zip文件。我使用cordova-plugin-zip来实现这一目标。但是我的zip文件与文件夹和文件混合在一起。当我尝试解压缩它时,它只提取文件,文件夹被忽略。如何使这成为可能?谢谢!

这是我的一些代码。

 public static UnZipFile(filename: string, extractedpath: string) {

  var promise = new Promise<string>((resolve, reject) => {
     AppBridge.createDirectory(extractedpath); //This creates the directory path
     var filePath: string = AppBridge.getZipName(filename); //Get the zip file name
     var destination: string = AppBridge.outputDirectory(extractedpath); //Get the output directory

     zip.unzip(filePath, destination);

   });
}

AppBridge是用C#编写的,我的项目以某种方式混合在.Net Core和Cordova中。这就是为什么C#有限的可以做什么。我只是用它来获取Windows的一些信息。

1 个答案:

答案 0 :(得分:0)

您似乎不是第一个遇到同样问题的人:Recursive unzip? #12 问题可能是因为您在只读文件系统上解压缩。

你能改变一下吗?

另一个解决方案是使用另一个似乎有效的plugin。但我没有尝试过自己。

相关问题