1

This is my source code in C#:

private void button11_Click(object sender, EventArgs e)
{
    FolderBrowserDialog fbd = new FolderBrowserDialog();

    fbd.SelectedPath = Directory.GetCurrentDirectory() + "\\Slides";

    DialogResult result = fbd.ShowDialog();
}

When you click on the button the FolderBrowserDialog will be shown. My problem is that the last folder named Slides here is not open by default in the ShowDialog form.

I want something like this when the Dialog is shown:

enter image description here

And not like this while sub directories of Slides are closed:

enter image description here

Notice: there can be different folders in the Slides directory.

UserMat
  • 600
  • 4
  • 10
  • 27
  • It shouldn't behave like that.... have you checked where does `Directory.GetCurrentDirectory()` actually point? It may not be the Debug folder. – bokibeg Oct 15 '15 at 11:32
  • Can't you just do `fbd.SelectedPath = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location) + "\\Slides\\";` – kevintjuh93 Oct 15 '15 at 11:33
  • @kevintjuh93 I used your method. But it didn't work for me. – UserMat Oct 15 '15 at 11:36
  • I edited it, does it work now? Also you might want to seperate it and print the directory. – kevintjuh93 Oct 15 '15 at 11:36
  • @bokibeg Can you please show me an example. – UserMat Oct 15 '15 at 11:37
  • Just put `System.Diagnostics.Debug.WriteLine("Dir > " + Directory.GetCurrentDirectory());` before the dialog and you may find out that it's not the directory where your app is located. – bokibeg Oct 15 '15 at 11:41
  • @kevintjuh93 No it still doesn't work – UserMat Oct 15 '15 at 11:43
  • If you want to get the path where the executable is, check out: http://stackoverflow.com/questions/15653921/get-current-folder-path – kevintjuh93 Oct 15 '15 at 11:45
  • @kevintjuh93 No I'm not looking for executable file. There is only folders and a lot of picture in every directory. Sometimes there is nothing in Slides folder. No folder and no file. – UserMat Oct 15 '15 at 11:47
  • Well I can't view the images you posted because of this proxy on my work. Which I think causes the fact that I have no idea what you actually want now. Where is the `Slides` folder located. – kevintjuh93 Oct 15 '15 at 11:48

0 Answers0