How to fix 'FolderBrowserDialog not showing Network shared folders on Win10'
By FoxLearn 12/10/2024 4:46:11 AM 45
C# FolderBrowserDialog not showing Network shared folders Windows 10
If you have a Windows application that uses the FolderBrowserDialog
to allow the user to select a folder, you may encounter issues with network shared folders not appearing.
For example:
FolderBrowserDialog fbd = new FolderBrowserDialog(); fbd.Description = "Custom Description"; if (fbd.ShowDialog() == DialogResult.OK) { var filePath = fbd.SelectedPath; }
Ensure that Network Discovery and File and Printer Sharing are enabled in the Network and Sharing Center. This allows shared folders to be visible to your application.
For shared folders to be visible via FolderBrowserDialog
, SMB (Server Message Block) protocols must be enabled, especially for network shares on other machines.
Make sure the user has access to the network shared folder (either as a guest or with a specific user credential).
The only way to resolve the issue of network shared folders not appearing in FolderBrowserDialog
is by adding a specific Registry key programmatically.
You can create a method in C# that adds the necessary Registry subkey with a DWORD value to enable network folder visibility.
public void ConfigureRegistry() { // Open the LocalMachine registry key with 64-bit view RegistryKey localMachine = RegistryKey.OpenBaseKey(RegistryHive.LocalMachine, RegistryView.Registry64); // Open the specific subkey or create it if it doesn't exist var reg = localMachine.OpenSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", true); if (reg == null) reg = localMachine.CreateSubKey("Software\\Microsoft\\Windows\\CurrentVersion\\Policies\\System", true); // Check if the "EnableLinkedConnections" value is already set if (reg.GetValue("EnableLinkedConnections") == null) { // Set the DWORD value to 1 reg.SetValue("EnableLinkedConnections", 1, RegistryValueKind.DWord); } }
The application must be run with elevated privileges (admin rights) for this code to modify the system registry.
- How to fix 'Cross-thread operation not valid: Control accessed from a thread other than the thread it was created on'
- How to use BlockingCollection in C#
- Calculating the Distance Between Two Coordinates in C#
- Could Not Find an Implementation of the Query Pattern
- Fixing Invalid Parameter Type in Attribute Constructor
- Objects added to a BindingSource’s list must all be of the same type
- How to use dictionary with tuples in C#
- How to convert a dictionary to a list in C#