我试图解压缩文件,但我总是有
访问路径' C:\ Users \ Kosov Denis \ Downloads \ 12.epub'是 拒绝。
我做了什么?
await Task.Run(() =>
{
ZipFile.ExtractToDirectory(file.Path,
ApplicationData.Current.LocalCacheFolder.Path +
string.Format(@"\{0}", file.Name.Replace(file.FileType, "")));
});
答案 0 :(得分:3)
StorageFolder folder;
folder = ApplicationData.Current.LocalFolder;
//Open the file picker
var _openFile = new FileOpenPicker();
_openFile.SuggestedStartLocation = PickerLocationId.DocumentsLibrary;
_openFile.ViewMode = PickerViewMode.List;
_openFile.FileTypeFilter.Add(".zip");
StorageFile file = await _openFile.PickSingleFileAsync();
//Read the file stream
Stream a = await file.OpenStreamForReadAsync();
//unzip
ZipArchive archive = new ZipArchive(a);
archive.ExtractToDirectory(folder.Path);