我的应用程序是通用窗口平台应用程序。我尝试实现运行时组件来解压缩压缩文件夹。我的要求之一是可以处理超过260个字符的路径。'无法在UWP上加载文件或程序集System.IO.Compression'
public static IAsyncActionWithProgress <string> Unzip(string zipPath, string destination) {
return AsyncInfo.Run <string> (async(_, progress) => {
var zipFile = await StorageFile.GetFileFromApplicationUriAsync(new Uri(zipPath));
try {
Stream stream = await zipFile.OpenStreamForReadAsync();
ZipArchive archive = new ZipArchive(stream);
archive.ExtractToDirectory(destination);
} catch (Exception e) {
Debug.WriteLine(e.Message);
}
});
}
我试图执行我的方法得到下面的异常消息:
System.IO.FileNotFoundException: Could not load file or assembly 'System.IO.Compression, Version=4.1.1.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' or one of its dependencies. The system cannot find the file specified.
at Zip.Zip.<>c__DisplayClass0_0.<<Unzip>b__0>d.MoveNext()
at System.Runtime.CompilerServices.AsyncTaskMethodBuilder.Start[TStateMachine](TStateMachine& stateMachine)
at Zip.Zip.<>c__DisplayClass0_0.<Unzip>b__0(CancellationToken _, IProgress`1 progress)
at System.Thread (~4340)
我试图用的NuGet添加System.IO.Compression但我仍然得到同样的错误。压缩文件和目标文件夹存在。
我试图在Visual Studio 2015而不是Visual Studio 2017上调试我的项目,发现我可以使用System.IO.Compression,但是对路径长度有限制。