Answered by:
PathIO.ReadTextAsync error 'Access denied'

Question
-
Hello.
I have created a C # DLL for Windows Store App.
I tested the DLL I created for testing the Windows Store App.
I wanted to read and parse xml file on my computer.
However, an error has occurred.
Error code is 'Access denied' (HRESULT 0x80070005) in PathIO.ReadTextAsync function.
private async Task<String> GetXmlFile(String xmlFileName) { String resString = null; try { String xmlFileString = await Windows.Storage.PathIO.ReadTextAsync(xmlFileName); // error occured resString = xmlFileString; } catch(Exception ex) { SystemDiagnostics.Debug.WriteLine("Exception! - " + ex.ToString()); } return resString; }
I have tested the DLL in Windows Tablet PC simulator.
The Argument, 'xmlFileName' is @"D:\Dev\DllTester\bin\Debug\test.xml"
It is not read only file, and the folder is not system folder, too.
I'm trying for days but could not find the cause.
I'm sorry I did not speak English well, so I used a translator in internet.
I need help, please.
Thank you.
Wednesday, October 30, 2013 8:07 AM
Answers
-
The error is correct. Your app doesn't have direct access to folders outside of its app data and install directories. It needs user permission to access other locations which the file system broker will then read on the app's behalf. See Skip the path: stick to the StorageFile for more details.
--Rob
- Marked as answer by gorzoshs Monday, November 4, 2013 2:12 AM
- Unmarked as answer by gorzoshs Monday, November 4, 2013 2:13 AM
- Proposed as answer by Dave SmitsMVP Monday, November 4, 2013 7:50 AM
- Marked as answer by Rob Caplan [MSFT]Microsoft employee, Moderator Tuesday, November 5, 2013 5:05 AM
Wednesday, October 30, 2013 3:03 PMModerator
All replies
-
You want to get xml text from your App package?
You need to know that Windows Store Apps can't get access to files in OS without using FileOpenPicker.
Metro apps can get files only from App Local Storage and from "KnownFolders", like picture library, music library, document library, video library.
So, you can use instead
Windows.ApplicationModel.Package
http://stackoverflow.com/questions/9552335/how-to-open-a-packaged-file-with-winrt
- Edited by Oleg Kurzov Wednesday, October 30, 2013 8:38 AM
Wednesday, October 30, 2013 8:37 AM -
The error is correct. Your app doesn't have direct access to folders outside of its app data and install directories. It needs user permission to access other locations which the file system broker will then read on the app's behalf. See Skip the path: stick to the StorageFile for more details.
--Rob
- Marked as answer by gorzoshs Monday, November 4, 2013 2:12 AM
- Unmarked as answer by gorzoshs Monday, November 4, 2013 2:13 AM
- Proposed as answer by Dave SmitsMVP Monday, November 4, 2013 7:50 AM
- Marked as answer by Rob Caplan [MSFT]Microsoft employee, Moderator Tuesday, November 5, 2013 5:05 AM
Wednesday, October 30, 2013 3:03 PMModerator -
Thank you for your answerMonday, November 4, 2013 2:14 AM