I tried to delete a folder which is present in the path "C:\Users\Default\AppData\Roaming". Usually I use the below code to delete the folder.
For deleting the folder present in the desktop,
if (Directory.Exists("folderpath"))
{
Directory.Delete("folderpath");
}
this line will delete the folder even if it is read only. If I copy the same folder and place it in this "C:\Users\Default\AppData\Roaming" location & run my code again I am getting the error
System.IO.IOException: 'Access to the path 'C:\Users\Default\AppData\Roaming\SampleFolder' is denied.'
I tried many other methods to delete the folder, but still facing the same issue. Kindly help.