1

I'm trying to unzip file, but i always had

Access to the path 'C:\Users\Kosov Denis\Downloads\12.epub' is denied.

What did i worng?

await Task.Run(() =>
            {
                ZipFile.ExtractToDirectory(file.Path,
                    ApplicationData.Current.LocalCacheFolder.Path +
                    string.Format(@"\{0}", file.Name.Replace(file.FileType, "")));
            });
Raktim Biswas
  • 4,011
  • 5
  • 27
  • 32
Denis Kosov
  • 697
  • 6
  • 21
  • 2
    this is access permission issue in uwp app [Read here](http://stackoverflow.com/questions/33082835/windows-10-universal-app-file-directory-access) which folders and Directory you can Access. – Irfan Jun 29 '16 at 04:22

1 Answers1

4

I have encountered the same problem with you, my google for a long time found UWP seems not directly through the path to access the file, if you want to visit the local file, you need to use the file pickup, see:hele. I used the curve to solve this problem:

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);

ZipArchive Class

fiercex
  • 41
  • 3