C # source code example for obtaining all the shared files and paths on the Local Computer
Today, someone in the group asked a question: How do I get the paths of all the shared files on the local computer? So I wrote it first. Now I can paste the code and share it with me. It is relatively simple and not well written. Please forgive me.
Complete code:
Using System;
Using System. Management;
Using System. Windows. Forms;
/*
*/
Namespace getaskfolder
{
Public partial class MainForm: Form
{
Public MainForm ()
{
InitializeComponent ();
}
Private void btnStart_Click (object sender, EventArgs e)
{
// Manually add and reference System. Management
ManagementObjectSearcher searcher = new ManagementObjectSearcher ("select * from win32_share ");
Foreach (ManagementObject share in searcher. Get ())
{
Try
{
String name = share ["Name"]. ToString ();
String path = share ["Path"]. ToString ();
LstPath. Items. Add (name + "--" + path );
}
Catch (Exception ex)
{
Console. WriteLine (ex. Message );
}
}
}
}
}
File Download: 1 http://www.ctdisk.com/file/5351988 alternate address 2 http://flydoos.ys168.com/
If you cannot open the VS2010 project, please download Visual Studio Version 1.1, and then you will be able to open it.
From Apsara software Studio