Is there any way I can restrict a user to select files from only a particular directory in C#? It should not be allowed to browse other folders.
Not possible with the standard .NET wrappers. Reject the path with the FileOk event.
If you can count on your program running on Vista and up then you could consider using the CommonFileDialog class in the Windows API Code Pack. It has a FolderChanging event that can be canceled.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With