Is it possible to make a FolderBrowserDialog's default path show up in a library instead of the actual disk?

前端 未结 4 1700
梦谈多话
梦谈多话 2021-01-07 18:26

I know that if I set SelectedPath before I show the dialog I can get it to have a folder open by default when the dialog opens. However, the folder I want to us

相关标签:
4条回答
  • 2021-01-07 18:40

    Just set the path Libraries\VetCentric... before you open should do it I think.

    0 讨论(0)
  • 2021-01-07 18:46

    Set your root folder and selected path as such and it will auto-scroll there for you on the dialog opening:

    FolderBrowserDialog dlg = new FolderBrowserDialog();
    dlg.RootFolder = Environment.SpecialFolder.MyComputer;
    dlg.SelectedPath = @"E:\Vetcentric";
    dlg.ShowDialog();
    

    enter image description here

    The problem you run into is that if you watch the property assignments after selecting a folder located in the libraries hierarchy, it will still assign it to the genereic path that you would get via going through my computer.

    0 讨论(0)
  • 2021-01-07 18:59

    Use a Reset() call. This will make it auto-scroll.

            string prevpath = folderBrowserDialog1.SelectedPath;
            folderBrowserDialog1.Reset();
            folderBrowserDialog1.SelectedPath = bc.myWorkingDir;
            folderBrowserDialog1.ShowNewFolderButton = true;
    
            DialogResult dr = folderBrowserDialog1.ShowDialog();
            if (dr == DialogResult.OK || dr == DialogResult.Yes)
            {
                bc.myWorkingDir = folderBrowserDialog1.SelectedPath;
            }
            folderBrowserDialog1.SelectedPath = prevpath;
    
    0 讨论(0)
  • 2021-01-07 18:59

    The easiest way would probably be to put shortcuts to the folders you want into your starting folder. Then, just double click on the shortcut and it will take you to your folder.

    Otherwise you will need to use the Shell Library API See: Using Libraries in your Program

    0 讨论(0)
提交回复
热议问题