C# OpenFileDialog Lock To Directory

后端 未结 4 1631
萌比男神i
萌比男神i 2020-12-04 01:52

I am making a software that needs to ONLY be able allow people to select files and folders using the OpenFileDialog that are in the same directory as the program and that ar

4条回答
  •  心在旅途
    2020-12-04 02:29

    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.

提交回复
热议问题