0

I have created an application(windows) compiled with .NET 4.6.1 and used the FolderBrowserDialog object. When a button is pressed I execute this code:

FolderBrowserDialog folderbrowserdialog = new FolderBrowserDialog();

    folderbrowserdialog.Description = "Custom Description";

 if (folderbrowserdialog.ShowDialog() == DialogResult.OK)
 {
        filePath = folderbrowserdialog.SelectedPath ;

 }

what i get from the folderbrowserdialog(like foto)

enter image description here

however ,the folder browserdialog is not showing the networks shared folder(that the purpose of my app) otherewise just the pc folders.

but what i want to get it is the network shared folders which could i also access from windows 10 like foto here:

enter image description here

notes to be marked: i could not use the open file dialog cause i need the folder location. i desgined the Appto be opened just like admin by adding manisfest so the app is always starting like admin. the app should be comptiable with windows 10,7 note i know that i could try setting this registry option (could be broken in Win10):

HKEY_LOCAL_MACHINE/SOFTWARE/Microsoft/Windows/CurrentVersion/Policies/System
    EnableLinkedConnections=1

but it does not make a sense to add this registry by every customer PC

so is there any tipps to show the network shared folders in FolderBrowserDialog ?

BilalMr
  • 307
  • 3
  • 22
  • 1
    Mapped drives are user specific, so when the app runs as admin (a different user) it can't see the mapped network drives. – Equalsk Jun 18 '18 at 08:41
  • @Equalsk the admin user is the same user who logged in :) do u have any suggestion to let user(admin) see it ? – BilalMr Jun 18 '18 at 08:49
  • 1
    Does this help? https://stackoverflow.com/questions/18251983/folderbrowserdialog-doesnt-show-network-drives-in-win-2012 – Equalsk Jun 18 '18 at 08:53
  • @Equalsk i have just read this articel but it does not make a sense for me to add regedit key to every customer :( thanks any way :) – BilalMr Jun 18 '18 at 09:02

2 Answers2

0

Finally after reading many topics i found that the only solution is to add a Registry key programmatically so here how to add specfic C# Registry Subkey with dword value:

i wrote a method wich could all use it just to let you know after using it you have to restart the device after it ,it will work ;)

public void ConfigureWindowsRegistry()
{
    RegistryKey localMachine = RegistryKey.OpenBaseKey(Microsoft.Win32.RegistryHive.LocalMachine, RegistryView.Registry64); //here you specify where exactly you want your entry

    var reg = localMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", true);
    if (reg == null)
    {
        reg = localMachine.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", true);
    }

    if (reg.GetValue("EnableLinkedConnections") == null)
    {
        reg.SetValue("EnableLinkedConnections", "1", RegistryValueKind.DWord);
        MessageBox.Show(
            "Your configuration is now created,you have to restart your device to let app work perfektly");
    }
}
BilalMr
  • 307
  • 3
  • 22
0

I had the same issue. The reason of the problem: I was using as an Administrator. The mapped drives are related to the user, so I tried to use as an normal user and I could see the mapped drives.

Nath
  • 11
  • 2