我的應用程序是通用窗口平臺應用程序。我嘗試實現運行時組件來解壓縮壓縮文件夾。我的要求之一是可以處理超過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,但是對路徑長度有限制。