'Getting Access Denied on reading and writing txt file from Root Folder

I am trying to read .txt file in Maui Program from the location which I am getting from Path.GetPathRoot(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal));

I am getting access denied error.

What permissions have to give to the windows application.



Solution 1:[1]

Reading system root files requires administrator privileges

  1. Run Visual Studio as administrator.

  2. In solution explorer, add new item, select "Application Manifest File".

change

 <requestedExecutionLevel level="asInvoker" uiAccess="false" />

to

 <requestedExecutionLevel level="requireAdministrator" uiAccess="false" />

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 sync