Delete files by extension

1

How can I delete files from one folder per extension? "I got" the files with this code:

string[] arquivos = Directory.GetFiles(st.path, "*.xml", SearchOption.AllDirectories);

But I do not know how to delete

    
asked by anonymous 14.11.2017 / 17:57

1 answer

6

Because you have a collection of string s with the paths of the files, you can use the Delete " of class File .

foreach(var arq in arquivos)
{
    File.Delete(arq);
}
    
14.11.2017 / 17:58