C # source code example for obtaining all the shared files and paths on the Local Computer

Source: Internet
Author: User

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
 


Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.