Access to file in UWP

喜夏-厌秋 提交于 2019-12-08 06:45:35

问题


I'm developing an video player for Windows Universal 10 (target version: 10.0.10240.0)

I'm able to launch files from PC to my app and play video as well as I want. The problem starts with I want when I launch a video, subtitle with the same name of video in the folder get it in application, for example I have these files in somewhere in my pc:

The.Originals.S03E14.480p.mkv

The.Originals.S03E14.480p.srt

I want when i Launched this mkv file, can access to srt file too. the code I used:

StorageFile file = args.Files[0] as StorageFile; // Launched file
string filePath = file.Path;
filePath = filePath.Replace(Path.GetExtension(filePath), ".srt");
StorageFile file2 = await StorageFile.GetFileFromPathAsync(filePath);

but for getting subtitle, it gives me ACCESS DENIED exception.

Is this possible to get subtitle without launching them?

thanks


回答1:


The short answer is no. The best solution would be to allow user specify SRT file manually via file picker. You can access only files which user has picked via picker. You can also access Video library folder (it should be specified in manifest permissions), but I assume you need to play file from any location. For more info take a look at the following link: https://stackoverflow.com/a/33083243/1099716 For example, even microsoft was unable to implement normal image viewer. Native windows 10 image viewer app can't navigate between pictures, since it can't access files in the same folder.



来源:https://stackoverflow.com/questions/35681017/access-to-file-in-uwp

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!