Access to file denied on app's second run

后端 未结 1 1902
遇见更好的自我
遇见更好的自我 2021-01-21 10:55

I\'m facing a weird issue, when trying to access file on SD card with code:

var path = @\"D:\\Test\\test.txt\";
try
{
             


        
1条回答
  •  臣服心动
    2021-01-21 11:23

    The picker allows access because the user provided the file to you, not the path. A winstore app should not be dependent upon a users drive / folder layout, that is why you don't have authority to access files by absolute path. In this case, we should firstly allow access to removable devices in manifest file, then we should use system's RemovebleDevices folder to access files of allowable types.

    Also it is strange you can work with the absolute path the first time. In my test device, I always get the UnauthorizedAccessException and "Access is denied" error if using absolute path. My device is of build 10586.11.

    0 讨论(0)
提交回复
热议问题