Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

open a file through URL in Win8 store app after build the package

I want to open a file through URL in Win8 store app. Below is the code.

var uri = new Uri(uriToLaunch);
var options = new Windows.System.LauncherOptions(); 
options.TreatAsUntrusted = false;
var success = await Windows.System.Launcher.LaunchUriAsync(uri, options);

Actually, the code runs well in the debug mode. And in that way, the file is opened.

The problem is, when I build the package, and re-install it through the package, the file won't open. I tracked the success value, and it returns false. The same thing happens when I try to open a file locally, it can be opened from the debug mode, but failed after building to a package.

Anyone has the experience to resolve it?

like image 712
Nosen Avatar asked Nov 13 '22 18:11

Nosen


1 Answers

Direct file/folder access is restricted in an Windows Store app. it is a sandboxed execution environment. There are designated folders that you can use to create and access files. for anything else you will need end user intervention.

look at classes: StorageFolder::GetFileAsync, StorageFile::OpenAsync and DataReader::LoadAsync.

like image 194
Joelcitizen Avatar answered Nov 15 '22 09:11

Joelcitizen