0

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();
}
Parrish Husband
  • 3,148
  • 18
  • 40
San
  • 65
  • 7

1 Answers1

1

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

Rob Caplan - MSFT
  • 21,714
  • 3
  • 32
  • 54
  • Added all capabilities and File Type Associations too .txt Still facing access denied exception. – San Sep 07 '18 at 08:24