document-picker icon indicating copy to clipboard operation
document-picker copied to clipboard

Windows - Picking directory doesn't actually give access to that directory

Open ghost opened this issue 3 years ago • 1 comments

Bug report

Summary

When picking a directory for windows and then trying to save a file there using react-native-fs, I get 'access denied'. The UWP documentation mentions you need to give access to the folder to allow it to be used.

I did a test by adding the below code to the PickDirectory c# method in react-native-document-picker and it fixed my issue

  // Application now has read/write access to all contents in the picked folder
                    // (including other sub-folder contents)
                    Windows.Storage.AccessCache.StorageApplicationPermissions.
                          FutureAccessList.AddOrReplace("PickedFolderToken", folder);

Requesting this be added to the code (or I can create a PR if preferable)

Environment info

npx react-native info output:

System:
    OS: Windows 10 10.0.19043
    CPU: (8) x64 Intel(R) Core(TM) i7-10610U CPU @ 1.80GHz
    Memory: 3.00 GB / 15.61 GB
  Binaries:
    Node: 14.15.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 6.14.8 - C:\Program Files\nodejs\npm.CMD
    Watchman: Not Found
  SDKs:
    Android SDK: Not Found
    Windows SDK:
      AllowDevelopmentWithoutDevLicense: Enabled
      AllowAllTrustedApps: Enabled
      Versions: 10.0.18362.0, 10.0.19041.0
  IDEs:
    Android Studio: Version  4.1.0.0 AI-201.8743.12.41.7199119
    Visual Studio: 16.10.31321.278 (Visual Studio Enterprise 2019)
  Languages:
    Java: javac 16
  npmPackages:
    @react-native-community/cli: Not Found
    react: 17.0.2 => 17.0.2
    react-native: 0.64.2 => 0.64.2
    react-native-windows: ^0.64.11 => 0.64.14
  npmGlobalPackages:
    *react-native*: Not Found

library version: 7.1.2

windows RN version: 0.64.11

ghost avatar Dec 13 '21 18:12 ghost

Hello, yes please, be so kind and create a PR.

There is some old folder picking logic there as well so feel free to clear it up if you want. I don't have windows so.. 🤷‍♂️😄 Thanks!

vonovak avatar Dec 13 '21 21:12 vonovak