I'm creating an UWP application to split CSV and Excel files. The user has to select a file in any folder on the machine and the application has to read the file. At the end of the process, the application has to save one or more files based on what the user wants.
When I try to read a CSV file with this code
using (var reader = new StreamReader(file))
using (var csv = new CsvReader(reader, config))
{
return csv.GetRecords<dynamic>();
}
I receive an error
System.UnauthorizedAccessException: 'Access to the path 'C:\Users\enric\Downloads\combined_data.csv' is denied.'
I checked the capabilities in the Package.appxmanifest
but there is none related to files or folders. There is only Removable Storage
that seems similar to what I'm looking for but it doesn't work.
In the Microsoft documentation, I read to add a custom capability
<Capabilities><uap:Capability Name="documentsLibrary"/></Capabilities>
but it doesn't work either.