【发布时间】:2017-09-18 13:13:39
【问题描述】:
我的应用程序是通用窗口平台应用程序。我尝试实现一个运行时组件来解压缩一个压缩文件夹。我的要求之一是可以处理超过 260 个字符的路径。
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,但仍然遇到相同的错误。 zip 文件和目标文件夹存在。
我尝试在 Visual Studio 2015 而不是 Visual Studio 2017 上调试我的项目,发现我可以通过这种方式使用 System.IO.Compression,但路径长度存在限制。
【问题讨论】:
标签: c# uwp nuget windows-10-universal zipfile