// GetShareReport.cs // // Reports Network Shares via WMI (Win32_Share). // // Requires the System.Management package: // dotnet new console -o ShareReport // dotnet add package System.Management // (replace the generated Program.cs with this file, then dotnet run) // On .NET Framework, System.Management is already available — just // add a reference to it in your project. using System; using System.Management; var searcher = new ManagementObjectSearcher("SELECT Name, Path, Description, Type FROM Win32_Share"); int count = 0; foreach (ManagementObject item in searcher.Get()) { Console.WriteLine($"Name: {item["Name"]}"); Console.WriteLine($"Path: {item["Path"]}"); Console.WriteLine($"Description: {item["Description"]}"); Console.WriteLine($"Type: {item["Type"]}"); Console.WriteLine(new string('-', 40)); count++; } if (count == 0) { Console.WriteLine("No Network Shares found."); } else { Console.WriteLine($"\n{count} Network Shares found."); }