views:

716

answers:

3

Hello everyone! 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 are in deeper folders. I don't want the OpenFileDialog to be able to select stuff outside of the program's current directory. Is this possible to do in C# using the OpenFileDialog?

Please let me know

Thanks

+1  A: 

I'm afraid you can't. Most people created their own custom dialog for this scenario.

o.k.w
This seems to be correct. http://social.msdn.microsoft.com/Forums/en-US/csharpgeneral/thread/ae322891-fd55-4027-ae4f-53100ae32852
RCIX
A: 

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.

rAm
A: 

you can check if the path is correct after selected

if its just accept or send message box tell him you select different directory

Hashim Al-Arab