Tôi đang cố gắng xóa một thư mục và tất cả các tệp và thư mục trong thư mục đó, tôi đang sử dụng mã bên dưới và tôi gặp lỗi Folder is not empty
, bất kỳ đề xuất nào về những gì tôi có thể làm?
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);
}