【发布时间】:2011-01-14 10:17:50
【问题描述】:
我正在尝试删除一个文件夹以及该文件夹中的所有文件和文件夹,我正在使用下面的代码并收到错误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);
}
【问题讨论】: