I am developing a C# application which saves data to a folder. I want the folder to be restricted to all users in file explorer and only accessible programmatically through the application. So the application has full access to the folder, but it cannot be accessed directly through windows. How can I accomplish this?
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
回答1:
In Windows permissions are per-user, and there are no "per-application" permissions.
So to be able to prevent current user who runs the application from accessing the folder you'll need to run code that read/wirites the data in the folder to impersonate another account. Than you'll be able to set permission to be accessible to just that user.
Note that if user have admin privileges such user still can get access to the folder by overwriting your security settings.