N
Nico Vrouwe
Hi,
You'd have to do a recursive search, something like this (not tested)
public static void FindAndDelete( DirectoryInfo dirInfo, string pattern )
{
foreach( DirectoryInfo di in dirInfo.GetDirectories() )
FindAndDelete( di, pattern );
foreach( FileInfo fi in dirInfo.GetFiles( pattern ) )
fi.Delete();
}
then call it like:
FindAndDelete( new DirectoryInfo( @"C:\", "*.tmp" );
where C:\ is the dir where you want to start searching, and *.tmp the files
you want to delete.
Hope this helps,
Nico Vrouwe
You'd have to do a recursive search, something like this (not tested)
public static void FindAndDelete( DirectoryInfo dirInfo, string pattern )
{
foreach( DirectoryInfo di in dirInfo.GetDirectories() )
FindAndDelete( di, pattern );
foreach( FileInfo fi in dirInfo.GetFiles( pattern ) )
fi.Delete();
}
then call it like:
FindAndDelete( new DirectoryInfo( @"C:\", "*.tmp" );
where C:\ is the dir where you want to start searching, and *.tmp the files
you want to delete.
Hope this helps,
Nico Vrouwe