Delete files

  • Thread starter Thread starter David
  • Start date Start date
As bizarre as this sounds, there is no easy way to delete files using a
wildcard using the standard System.IO namespace. So you have a couple
of choices. It's possible shell out to the cmd and execute the delete
there. Alternatively, there is a Kill function in the
Microsoft.VisualBasic namespace that does take a wildcard for deletion.

Hope that helps.

Bruce Johnson [.NET MVP]
http://www.objectsharp.com/blogs/bruce
 
Use Directory.GetFiles() to get a list of files, then loop through the list,
deleting each file.

--- Nick
 
Back
Top