2

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

Ondrej Janacek
  • 12,486
  • 14
  • 59
  • 93
kombsh
  • 387
  • 2
  • 3
  • 14
  • Hi @Ondrej Janacek , you just edited the question, no answer ? – kombsh Mar 20 '14 at 10:31
  • Yes, I removed a language tag (C#) from the title because it was redundant. I'm not in any way obligated to asnwer your question though and I don't feel like answering it since I don't know the answer. – Ondrej Janacek Mar 20 '14 at 11:08

0 Answers0