How do I use the OpenFileDialog class (in C#, WPF etc.) such that it opens on the Network area as default?
This does not work:
OpenFileDialog openFileDialog1 = new OpenFileDialog();
openFileDialog1.InitialDirectory = "Network";
I also tried having "\" as an InitialDirectory and that did not work.
I also tried having "\\" as an InitialDirectory and that did not work either.
I haven't tried it, but this should work:
openFileDialog1.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.NetworkShortcuts);
Environment.GetFolderPath
returns the path corresponding to an Environment.SpecialFolder
enumeration entry as a string.
Environment.SpecialFolder.NetworkShortcuts
is defined as
A file system directory that contains the link objects that may exist in the My Network Places virtual folder.