码迷,mamicode.com
首页 > 其他好文 > 详细

ManagementObjectSearcher

时间:2015-06-04 11:36:46      阅读:103      评论:0      收藏:0      [点我收藏+]

标签:

1.获取本地共享目录

 1    public static List<string> GetSharedFolders()
 2         {
 3 
 4             var sharedFolders = new List<string>();
 5 
 6             // Object to query the WMI Win32_Share API for shared files...
 7 
 8             var searcher = new ManagementObjectSearcher("select * from win32_share");
 9 
10             foreach (ManagementObject share in searcher.Get())
11             {
12 
13                 string type = share["Type"].ToString();
14 
15                 if (type == "0") // 0 = DiskDrive (1 = Print Queue, 2 = Device, 3 = IPH)
16                 {
17                     string path = share["Path"].ToString(); //getting share path
18 
19                     sharedFolders.Add(path);
20                 }
21 
22             }
23 
24             return sharedFolders;
25 
26         }

 

ManagementObjectSearcher

标签:

原文地址:http://www.cnblogs.com/JustYong/p/4551183.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!