我正在尝试删除一个文件夹以及该文件夹中的所有文件和子文件夹,我使用了下面的代码,但是出现了错误Folder is not empty
,请问有什么建议吗?
try
{
var dir = new DirectoryInfo(@FolderPath);
dir.Attributes = dir.Attributes & ~FileAttributes.ReadOnly;
dir.Delete();
dataGridView1.Rows.RemoveAt(dataGridView1.SelectedRows[i].Index);
}
catch (IOException ex)
{
MessageBox.Show(ex.Message);
}