Pztar
Pztar

Reputation: 4749

Open File Dialogs - setting the InitialDirectory location?

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. 

Upvotes: 1

Views: 1597

Answers (1)

asawyer
asawyer

Reputation: 17808

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 ;

Upvotes: 4

Related Questions