private void DelFiles(string path) { try { if (Directory.Exists(path)) { string[] filePath = Directory.GetFileSystemEntries(path); if (filePath.Length > 0) { foreach (var fPath in filePath) { if (File.Exists(fPath)) { try { FileInfo dlefile = new FileInfo(fPath); dlefile.Delete(); } catch (Exception ex) { MessageBox.Show(ex.Message); } } else { if (Directory.GetFileSystemEntries(fPath).Length>0) { DelFiles(fPath); } } } } } } catch (Exception ex) { MessageBox.Show(ex.Message); } }