Here is a very simple and elegant way to list or filter the files in a given directory.
The example below deletes all the files that end with the “.tmp” extension.
Below is the code sample:
There are some limitations that you need to be aware of:
1. This code will not recursively list/delete files.
2. It will also list the subfolder names (if any).