I have a winforms application. In its folder, (eg .../WinformsApp/Reports), there are several files.
Is there a way to ensure that if the user adds files to this folder, the app will not include them? At the moment the app gets all the files in the folder, but I don't want the app to include user-added folders.
It is possible to say "Get all the files, get a count, if at any time the file count is greater than the previous count ("get a 开发者_StackOverflow中文版count"), then the user has added files and do whatever.". Would this approach be reliable?
Thanks
Instead of loading all files from the folder, why not just load the specific files you want? If preventing modifications is absolutely necessary, you could even check against a pre-generated hash on the file count, or some other mechanism to verify that the files are unmodified.
Trying to check the count won't be reliable. The user could just delete one of yours and add their own, etc.
精彩评论