Method DeleteFiles
DeleteFiles(string?, string)
Deletes files in the specified folder that match the given search pattern.
public static bool DeleteFiles(string? pathToFolder, string searchPattern)
Parameters
pathToFolder
stringThe path to the folder where files will be deleted.
searchPattern
stringThe search pattern to match files (e.g., "*.txt").
Returns
- bool
true
if the operation succeeds or the folder does not exist;false
if an exception occurs during the operation.