Remove all files and directories except one
In our installer, we install several files and several subdirectories with files in them. I have been asked to make the uninstaller remove all directories and files except one specific subdirectory (let's call it dirA). When a user then re-installs (either by uninstalling then installing OR by installing over), the desired behavior is, check the files in dirA and if a file that is being extracted from the installer already exists, it should not overwrite it. If a file does not exist, it should be extracted into that directory.
I have seen solutions elsewhere in this forum for recursively removing all files and for writing a file only if it doesn't already exist. However, I haven't seen one that does both. Anyone have a good way of doing this?
I should also mention that the files that are in the installer could change regularly between builds. In other words, I need a method that does not hardcode the file names in the installer source file.
TIA for any ideas.