[英]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.