简体   繁体   中英

Unauthorized access in Filepicker in Windows Store App

hello guys im having troubles regarding this code:

string commander = "insert into tblUsers (username,password,Lname,Fname,email,address,promoenabled,privilegetype,profilepic) values ('" + txtUsername.Text + "','" + txtPassword.Password + "','" + txtLname.Text + "','" + txtFname.Text + "','" + txtEmail.Text + "','" + txtAddress.Text + "',0,0,'"+imgName+"')";
 RunCommandAsynchronously(commander, GetConnectionString());
StorageFile file = await StorageFile.GetFileFromPathAsync(imgLocation); //this causes System.UnauthorizedAccess

how can i permit my app to include other locations? i've been able to check all of my app's capabilities but still this error occurs, what do you think this error occurs?

Your app cannot open files outside of its own application path without the consent of the user (which the user provides by selecting the file directly through a picker). Through capabilities, the user can also consent to allow your application unlimited access, but only to specific storage folders (such as their Pictures or Music folder). There is no capability that allows your app to just access any random file on disk whenever it desires. You should make sure that imgLocation is in one of the consentable folders, or copy it inside your application path after a user has consented to you accessing that file.

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