Win API – Delete all files except some

Consider I want to write a program that delete all files in a given directory, except for few files which the user can define to preserve (by using a config file for example).
Is there a native way to do it? The direct approach is to loop over all the files and to decide for each of them if to call DeleteFile or not. But is it the right approach?

Thanks.


Source: windows

Leave a Reply