I am developing a Windows 8 Metro app, and we intend to deploy it to only a few tablets within our company. It's not meant for the Windows Store.
We need the app to access some directories on the company's network share, but forcing the user to use a FilePicker
isn't what we want.
Our first attempt was to use await StorageFolder.GetFolderFromPathAsync("J:\\");
. This didn't work, and produced the following exception:
An unhandled exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll
WinRT information: Cannot access the specified file or folder (J:\). The item is not in a location that the application has access to (including application data folders, folders that are accessible via capabilities, and persisted items in the StorageApplicationPermissions lists). Verify that the file is not marked with system or hidden file attributes.
Additional information: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
So we tried replacing "J:\"
with the network path the drive was mapped to. This also didn't work, and we got this exception:
An unhandled exception of type 'System.UnauthorizedAccessException' occurred in mscorlib.dll
WinRT information: Cannot access the specified file (\\domain\path\JDrive). Verify that there is a file type association declared in the manifest for this type of file and that the file is not marked with the system or hidden file attributes.
Additional information: Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
Our app has the following Capabilities:
Our app has no Declarations
This is all very reasonable for a Windows Store app, but is there any workaround for a simple in-house app that isn't going to the Store?
Here is a quickstart on file access in JavaScript and VB/C#/C++.
In addition, this article on file access and permissions in Windows Store apps might be useful. From this article, it looks like you are using the right capabilities, but there is a note:
Note: You must add File Type Associations to your app manifest that declare specific file types that your app can access in this location.
This makes sense with the error message that you're seeing. Can you try that? Here's an article on how to do it: http://msdn.microsoft.com/en-us/library/windows/apps/hh452684.aspx
I'm also assuming that you've already checked and ensured that the file that you want to access is not marked with the system or hidden file attributes (as per the error message).
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