I am using WMI query to get share folder:
public static List<string> GetNetworkShareFoldersList(string serverName)
{
List<string> shares = new List<string>();
// do not use ConnectionOptions to get shares from local machine
ConnectionOptions connectionOptions = new ConnectionOptions();
//connectionOptions.Username = @"Domain\Administrator";
//connectionOptions.Password = "password";
//connectionOptions.Impersonation = ImpersonationLevel.Impersonate;
ManagementScope scope = new ManagementScope("\\\\" + serverName + "\\root\\CIMV2",
connectionOptions);
scope.Connect();
ManagementObjectSearcher worker = new ManagementObjectSearcher(scope,
new ObjectQuery("select Name from win32_share"));
foreach (ManagementObject share in worker.Get())
{
shares.Add(share["Name"].ToString());
}
return shares;
}
Thanks to the link http://www.morgantechspace.com/2014/02/Get-or-List-Network-shares-in-CSharp-using-WMI.html
Now my question is is this wmi code depends on any Windows Service in local or remote machine?... bcoz I am getting 0 results from above code