Delete files by extension

Asked

Viewed 576 times

1

How can I delete files from a folder by extension? "Got" files with this code:

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

But I can’t delete

1 answer

6


How do you have a collection of strings with the file paths, you can use the method Delete class File.

foreach(var arq in arquivos)
{
    File.Delete(arq);
}

Browser other questions tagged

You are not signed in. Login or sign up in order to post.