C# OpenFileDialog Lock To Directory

I don’t see any out of the box support by the OpenFileDialog Control. However, you can try the following,

Set the InitialDirectory property to your program path. Then if a user selects a particular path outside of your program path, use the FileOk event to check this and bring him back to the InitialDirectory.

If you want much more control then you will have to write your custom dialog.

Leave a Comment