How to use the OpenFileDialog class, which opens by default in the "Network" area?

How to use the OpenFileDialog class (in C #, WPF, etc.), which opens by default in the "Network" area?

This does not work:

  OpenFileDialog openFileDialog1 = new OpenFileDialog();
  openFileDialog1.InitialDirectory = "Network";

I also tried having "\" as the InitialDirectory, and this did not work.

I also tried having "\\" as the InitialDirectory, and that didn't work either.

+5
source share
2 answers

I have not tried, but this should work:

openFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.NetworkShortcuts);

Environment.GetFolderPathreturns the path corresponding to Environment.SpecialFolderthe enumeration entry as a string.

Environment.SpecialFolder.NetworkShortcuts defined as

, , " ".

+8

Microsoft MSDN Magazine . , :


...

REG_SZ, . , (. 6 ). REG_DWORD.

6


0 2 ""
3
4
5
6
7 ""
8
9 10
12 ""
17
18
20

( ), , ID 18, . , @Nelson, , . , , , , , , - .

Update:

Windows 7 . :

OpenDialogPlaces o = new OpenDialogPlaces();
//o.Places.Add(18);
//o.Places.Add(5);
//o.Places.Add(6);
o.Init();
o.OpenDialog.ShowDialog();
o.Reset();

:

enter image description here

Windows:

enter image description here

, Microsoft ComDlg32, , .

enter image description here

+1

All Articles