简体   繁体   中英

Restricting users to access C drive in C#?

i have a winform to merge few file and save the merge files in a Directory.

The directory in which it is saved ,it deletes the whole files and subdirectory in it .

Now i want that the user should not be able to save the file in My Computer,C,D Drives.

User can choose the directory through FolderBrowserDialog.

How can i restrict the user in doing so?
Can u plz help out?

最简单的方法是使用Windows NTFS文件系统中的访问权限。

Perhaps you mean that the user chooses the directory using the FolderBrowserDialog ? In any case, neither the FolderBrowserDialog nor the SaveFileDialog offer any in-built means of restricting the user selection.

Your most straightforward option therefore is to validate the user's selection and check if it is not one of directories you have chosen to restrict access to. You could also set code permissions and disallow permission for your code to save files into the restricted folders.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM