Reputation: 65
The below code throws access denied exception.
var filename = @"\\MYTSP00491\TestApp\VersionDetails.txt";
var file = await StorageFile.GetFileFromPathAsync(filename);
var inputStream = await file.OpenSequentialReadAsync();
string fileContents;
using (var streamReader = new StreamReader(inputStream.AsStreamForRead()))
{
fileContents = await streamReader.ReadToEndAsync();
}
Upvotes: 0
Views: 522
Reputation: 21889
It looks like your use case here is to read a file from a UNC path. To do so your app will need capabilities appropriate for the network and a File Type Association for the types you need. See the table in the File access permissions Accessing additional locations documentation:
Universal Naming Convention (UNC) folders
A combination of the following capabilities is needed.
The home and work networks capability: - PrivateNetworkClientServer
And at least one internet and public networks capability: - InternetClient - InternetClientServer
And, if applicable, the domain credentials capability: - EnterpriseAuthentication
Note: You must add File Type Associations to your app manifest that declare specific file types that your app can access in this location.
Retrieve a folder using: StorageFolder.GetFolderFromPathAsync
Retrieve a file using: StorageFile.GetFileFromPathAsync
Upvotes: 1