Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top