-2
Files = Directory.GetFiles(localFilename, "*.html");

In the end i get many directories for example the first index in Files is:

C:\test\test\test.html

Second index:

C:\test\test\test1.html

I want to delete only the files: test.html,test1.html and so on...

  • thats a frequently asked question just google "delete files in directory c# recursive" – Sebastian L Sep 03 '14 at 10:39
  • Why do you get many directories? `localFilename` is a directory name. You could use [this overload](http://msdn.microsoft.com/en-us/library/ms143316(v=vs.110).aspx) tio specify `SearchOption.AllDirectories`. But the answer remains the same since `GetFiles` returns the full path not only the file-name. – Tim Schmelter Sep 03 '14 at 10:39

1 Answers1

2
foreach(var file in Files)
     File.Delete(file);
Selman Genç
  • 100,147
  • 13
  • 119
  • 184