我几个月来一直在使用以下代码,没有任何问题,突然之间,它抛出了“拒绝访问路径”异常。我一直在清单中使用“ BroadFileSystemAccess”,并且正在使用文件选择器来选择作为StorageFile参数传递的文件。我还确保该应用程序启用了FileAccess。
怎么了?经过数小时的调试和搜索后无法解决...
public async Task AddImageToPlaylist(StorageFile NewImage)
{
try {
using (ZipArchive archive = ZipFile.OpenRead(NewImage.Path))
{
foreach (ZipArchiveEntry member in archive.Entries)
{
NumSlides += 1;
AllFiles.Add(new imgitem { type = "zip", zipname = NewImage.Path, filepath = member.FullName, imgname = NewImage.Name, imgsize = (ulong)member.Length, imgdate = member.LastWriteTime, index = NumSlides, ImgRating = 0 });
}
}
}
catch (Exception)
{
await Windows.ApplicationModel.Core.CoreApplication.MainView.CoreWindow.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, () => { MessageBlock.Text = "Exception encountered loading ZIP file"; });
}
}