简体   繁体   English

Windows.Storage.Compression解压缩压缩文件夹

[英]Windows.Storage.Compression UnZip Compressed Folder

I am working on a UWP app that can only use .Net Core libraries. 我正在开发只能使用.Net Core库的UWP应用。 I have been trying to implement a zip/unzip tool. 我一直在尝试实现zip / unzip工具。 I have a few questions does Windows.Storage.Compression support the standard GZIP/ZIP file formats? 我有几个问题,Windows.Storage.Compression是否支持标准的GZIP / ZIP文件格式? I have written some test code to extract a ZIP i created in windows but it return a 0 byte length file. 我已经编写了一些测试代码来提取我在Windows中创建的ZIP,但它返回的文件长度为0字节。

var sourceFilename = "test.zip";
      var sourceFile = await ApplicationData.Current.TemporaryFolder.GetFileAsync(sourceFilename);

      var decompressedFilename = "test.xlsx"; // sourceFile.Name + ".decompressed";
      var decompressedFile = await ApplicationData.Current.TemporaryFolder.CreateFileAsync(decompressedFilename, CreationCollisionOption.GenerateUniqueName);

      //Read the file stream
      using (var compressedInput = await sourceFile.OpenSequentialReadAsync())
      using (var decompressor = new Decompressor(compressedInput))
      using (var decompressedOutput = await decompressedFile.OpenAsync(FileAccessMode.ReadWrite))
      {
        var bytesDecompressed = await RandomAccessStream.CopyAsync(decompressor, decompressedOutput);     
      }

As mentioned it returns a zero length file. 如前所述,它返回零长度的文件。

Further to this question I really want to develop a way to extract an existing zip (I have hundreds of them with thousands of items) using system.windows.compression into a folder of files. 进一步解决这个问题,我真的想开发一种使用system.windows.compression将现有zip(我有成百上千个项目)提取到文件文件夹中的方法。 (I have this working fine in Android and IOS platforms but cannot see how to make this simple task with in UWP 10 (The system cannot use System.IO.Compression.ZipFile - due to Cordova UWP Windows 10 restrictions). (我在Android和IOS平台上都能正常工作,但是看不到如何在UWP 10中完成此简单任务(由于Cordova UWP Windows 10的限制,系统无法使用System.IO.Compression.ZipFile)。

I have worked through https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/Compression/js - which is where the file sample came from above but again cannot open a .zip made with Windows 10 or 7Z. 我已经通过https://github.com/Microsoft/Windows-universal-samples/tree/master/Samples/Compression/js进行了工作-这是文件示例来自上面的地方,但同样无法打开使用Windows 10制作的.zip文件或7Z。

Further to this question I really want to develop a way to extract an existing zip (I have hundreds of them with thousands of items) using system.windows.compression into a folder of files. 进一步解决这个问题,我真的想开发一种使用system.windows.compression将现有zip(我有成百上千个项目)提取到文件文件夹中的方法。 (I have this working fine in Android and IOS platforms but cannot see how to make this simple task with in UWP 10 (The system cannot use System.IO.Compression.ZipFile - due to Cordova UWP Windows 10 restrictions). (我在Android和IOS平台上都能正常工作,但是看不到如何在UWP 10中完成此简单任务(由于Cordova UWP Windows 10的限制,系统无法使用System.IO.Compression.ZipFile)。

You can use Cordova-plugin-zeep to extract an existing zip file. 您可以使用Cordova-plugin-zeep提取现有的zip文件。 Or you can create your own plugin leveraging System.IO.Compression.ZipFile like this for zip/unzip logic. 或者你可以创建自己的插件利用System.IO.Compression.ZipFile这样的压缩/解压缩逻辑。 For details, please refer to Creating a Windows Plugin in C++ or managed code . 有关详细信息,请参阅使用C ++或托管代码创建Windows插件

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

相关问题 解压缩Cordova中的文件和文件夹 - Unzip files and folder in Cordova Cordova从www文件夹解压缩文件 - cordova unzip files from www folder 在内部存储器中创建文件夹 - Creation of folder inside the internal storage 如何在内部存储器上创建文件夹? - How to create a folder on the internal storage? Windows 10 通用应用程序 - 我可以使用纯 JavaScript 解压缩应用程序中的文件吗? - Windows 10 Universal Application - Can I unzip files in the application using pure JavaScript? 如何在Windows Phone中解压缩文件(使用Visual Studio Apache Cordova Community) - How to unzip a file in windows phone (using Visual Studio Apache Cordova Community) 在Windows 8的Cordova中,长期存储的正确存储选项是什么? - In Cordova for Windows 8, what is the correct storage option for longterm storage? 如何在Intel XDK中访问设备本地存储文件夹路径 - how to access device local storage folder path in Intel XDK 如何将 www 文件夹(html 文件)从内部存储加载到 BBDCordovaWebview? - How to load www folder(html files) from internal storage to BBDCordovaWebview? Cordova Windows App无法使用依赖项文件夹构建appx - Cordova Windows App not building appx with dependencies folder
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM