Open File Dialogs - setting the InitialDirectory location?

Go To StackoverFlow.com

1

How can I set the initial directory of where an Open File Dialog appears? I'd like to change it to the images folder that sits in my /bin/Debug folder. I just can't get it to work.

opdPicture.Title = "Choose a Picture";
opdPicture.InitialDirectory = ""; //Don't know what to set this to. 
2012-04-05 22:10
by Pztar
What did you try, and what happened - Kendall Frey 2012-04-05 22:12
Well I'm not exactly sure how to approach it. I've tried "/bin/Debug/images" or just "/images." But the only examples I can find online are from "C:\" which is not what I want - Pztar 2012-04-05 22:17
Did you try "Images" - Kendall Frey 2012-04-05 22:20


4

Application.StartupPath will give you the directory the exe is in, so I imagine you want to use Path.Combine to get the images directory relative to the startup path.

var imagePath = System.IO.Path.Combine( Application.StartupPath, "images" )

opdPicture.Title = "Choose a Picture";
opdPicture.InitialDirectory = imagePath ;
2012-04-05 22:17
by asawyer
Ads