Re: Save file in Restricted folder
Windows file permissions can get quite complex. In order to save the files they will have to have low-level permission CREATE FILES/WRITE DATA to the folder itself. Also, if I recall correctly, WRITE ATTRIBUTES on the file being created. To determine whether you have any file conflicts, that means READ DATA on the folder and READ ATTRIBUTES on the created file have to be in the mix.
What happens if the user tries to update something and thus tries to save the file a second time by the user ID? You would get naming duplicates which would be a really big problem for your program to resolve if the folder is restricted. You would either have to trap an error or be able to know of this conflict ahead of time (using a method to read the directory).
Now you MIGHT consider that you could declare the folder to be "hidden" so that the users won't immediately know it is there. However, even a user with limited knowledge of Windows would be able to find how to show hidden files. This would be a form of "security through obscurity" and is generally doomed to failure (in the sense of being a secure method).
If you have users who cannot be trusted to leave things alone, your problem isn't in your code, it is in the users' heads and must be solved by reprogramming THEM. I.e. via training or warnings or threats (if necessary).
I'm a certified grandpa (3 times now) and proud of it.
Retired over one year and survived being home all day with the wife. She must really love me.
If I have helped you, please either click the thanks or click the scales.