1
Answer

Shared Drives - Domain ID

Hello all....
 
I once again need help....
 
My requirement is -
1. User will input domain name. Domain Name - when we press "Ctrl + Alt + Delete" to login the system.
 
2. I need to get all the shared drives of that particular user or domain id.
 
How do I get this list ?
 
These shared drives are seen in "My Computer" . But  I need to get it in C#.NET Code.
Answers (1)
0
Laxmidhar Sahoo

Laxmidhar Sahoo

NA 2.3k 1.4k 7y
the bellow code will display your login user shared drive with folders
 
  1. using System;  
  2. using System.Collections.Generic;  
  3. using System.ComponentModel;  
  4. using System.Data;  
  5. using System.Drawing;  
  6. using System.Linq;  
  7. using System.Text;  
  8. using System.Threading.Tasks;  
  9. using System.Windows.Forms;  
  10. using System.Management;  
  11. using System.Management.Instrumentation;  
  12. namespace webresponse  
  13. {  
  14.     public partial class Form2 : Form  
  15.     {  
  16.         public Form2()  
  17.         {  
  18.             InitializeComponent();  
  19.         }  
  20.   
  21.         private void button1_Click(object sender, EventArgs e)  
  22.         {  
  23.   
  24.             ManagementClass mc = new ManagementClass("Win32_Share");  
  25.             ManagementObjectCollection mcCollection = mc.GetInstances();  
  26.   
  27.             foreach (ManagementObject mo in mcCollection)  
  28.             {  
  29.                 ListViewItem lv = new ListViewItem(Convert.ToString(mo["Path"]));  
  30.                 listView1.Items.Add(lv);  
  31.                  
  32.             }  
  33.               
  34.         }  
  35.     }  
  36. }