How to fix 'FolderBrowserDialog not showing Network shared folders on Win10'
By FoxLearn 12/10/2024 4:46:11 AM 275
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.
- Using the OrderBy and OrderByDescending in LINQ
- Querying with LINQ
- Optimizing Performance with Compiled Queries in LINQ
- MinBy() and MaxBy() Extension Methods in .NET
- SortBy, FilterBy, and CombineBy in NET 9
- Exploring Hybrid Caching in .NET 9.0
- Using Entity Framework with IDbContext in .NET 9.0
- Primitive types in C#