I am currently writing my first UWP app just to learn the ropes. I am building a small application that pulls data from downloaded facebook-archive.
But when I try to open the file (even though everybody has full access) I get an UnauthorizedException. I don't understand this and I haven't found anybody having this problem with just any old file (there are many people having problems with more specific scenarios but not just a simple file on their hard drive)
System.UnauthorizedAccessException was unhandled by user code
HResult=-2147024891
Message=Access to the path 'C:\Users\patri\Downloads\facebook-100004420950389\html\messages.htm' is denied.
Source=System.IO.FileSystem
StackTrace:
at System.IO.WinRTIOExtensions.<TranslateWinRTTaskCore>d__1`1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.IO.WinRTFileSystem.<OpenAsync>d__1.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at System.IO.WinRTFileSystem.Open(String fullPath, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options, FileStream parent)
at System.IO.FileStream.Init(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.Xml.XmlSystemPathResolver.GetEntity(Uri uri, String role, Type typeOfObjectToReturn)
at System.Xml.XmlTextReaderImpl.FinishInitUriString()
at System.Xml.XmlReaderSettings.CreateReader(String inputUri, XmlParserContext inputContext)
at System.Xml.Linq.XDocument.Load(String uri, LoadOptions options)
at Facebookalyzer.FacebookArchiveParser.PopulateArchiveFromHtml(String filePath, FacebookMessageArchive archive)
at Facebookalyzer.FacebookArchiveParser.<>c__DisplayClass0_0.<ExtractAllChatMessages>b__0()
at System.Threading.Tasks.Task.Execute()
InnerException:
Does anybody know why I am getting this exception? Or is it just a fact that you should not access files on your hard drive directly in UWP-Apps (which would make me question though Why they provide a file open dialog if that was the case)