폴더 및 폴더 내의 모든 파일 및 폴더를 삭제하려고하는데 아래 코드를 사용하면 오류가 발생합니다. Folder is not empty
, 어떤 제안 사항이 있습니까? 내가 할 수있는?C# 폴더 및 폴더 내의 모든 파일 및 폴더 삭제
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);
}
왜 Google을 빨리 읽었습니까? – reggaeguitar
true로 설정하면 path의 모든 dir, subdir 및 파일이 삭제됩니다. 경로 자체도 삭제됩니까? false로 설정하면 경로가 삭제되고 path의 하위 디렉토리와 파일은 삭제됩니까? – helloworld