简体   繁体   中英

Can you access a picked StorageFile from its Path? - UWP

I need to be able to access a file from it's path in a UWP application.

The file is first selected by the user using OpenFilePicker. I then need to pass this file on to an FFmpeg wrapper that sets its input from a file path. Currently, I get access denied errors for any file that is outside the apps local storage (as expected).

FileOpenPicker filePicker = new FileOpenPicker();
filePicker.ViewMode = PickerViewMode.Thumbnail;
filePicker.FileTypeFilter.Add("*");


var file = await filePicker.PickSingleFileAsync();


FFMpegArguments
   .FromInputFiles(file.Path.ToString())

Is there a way to retain the apps permission to this file when it is accessed by a path string (file.Path.ToString()) rather then a storage file instance? Have been looking into FutureAccessList but that seems to only provide another storage file instance later rather then allow for path access to the same file. I'd like to not enable broad file system access as I only need access to a single file that has already been picked by the user.

Thanks!

This is excepted behavior. UWP apps are not allowed to use Path by default. UWP apps have a restricted broadFileSystemAccess capability . This capability allows UWP apps to access to all the files in the system. But you could only use the Storage API to get files via path.

For your scenario, you might need to check if the FFMpegArguments object has other methods to create instances like using steam.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM