我尝试删除路径"C:\Users\Default\AppData\Roaming“中的文件夹。我通常使用下面的代码来删除文件夹。
为了删除桌面中存在的文件夹,
if (Directory.Exists("folderpath"))
{
Directory.Delete("folderpath");
}此行将删除该文件夹,即使它是只读的。如果我复制相同的文件夹并将其放在"C:\Users\Default\AppData\Roaming“位置,然后再次运行我的代码,我会收到错误消息
System.IO.IOException: 'Access to the path 'C:\Users\Default\AppData\Roaming\SampleFolder' is denied.'我尝试了许多其他方法来删除文件夹,但仍然面临相同的问题。请帮帮忙。
https://stackoverflow.com/questions/54283980
复制相似问题