views:

347

answers:

2

Hi ,

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?

+2  A: 

The simplest way of doing it would be use the access rights in Windows NTFS file system.

Umair Ahmed
How to do that?
crazy_itgal
http://www.google.com.pk/search?q=ntfs+file+permissions
Umair Ahmed
http://www.windowsecurity.com/articles/Understanding-Windows-NTFS-Permissions.html
Umair Ahmed
+2  A: 

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.

Cerebrus