I'm building an internal company app and trying to read and write files on local and network drives. I have added the broadFileSystemAccess restricted capability. I am able to list directories, but I get System.UnauthorizedAccessException when trying to read or write any files.
I have found that if I also add file type associations for the types of files I am reading or writing, then it works. However, this also means that the app gets registered with Windows to open those file types, which I do not want.
// This line works once I enable broadFileSystemAccess.
StorageFolder folder = await StorageFolder.GetFolderFromPathAsync(@"Path\to\folder");
// This line works only after I add a pdf file type association.
StorageFile file = await StorageFile.GetFileFromPathAsync(@"Path\to\file.pdf");
As Stefan Wick MSFT said, after add broadFileSystemAccess capability, you also need to manually enable broad file system in File System setting page. For getting the setting page, you could search file system keywords in setting app home page.

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With