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

 

If there is reprint, please indicate the source: http://www.cnblogs.com/flydoos/archive/2012/03/15/2397820.html

 

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.CodePost it and share it. It is relatively simple and not well written. Please forgive me.

 

 

 

Complete code:

Using System;
Using System. Management;
Using System. Windows. forms;
/*
*
* Author: between Niu A and Niu C
* Q: 277922950 C #/Java technology exchange group: 96020642
* Weibo: Http://weibo.com/flydoos
* Blog: Http://flydoos.cnblogs.com
* Date: 2012-03-15
*
  */
Namespace Getaskfolder
{
Public Partial Class Mainform: Form
{
Public Mainform ()
{
Initializecomponent ();
}

Private Void Btnstart_click ( Object Sender, eventargs E)
{
// You need to manually add 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 backup address 2

 

If the vs2010 project cannot be opened, download it hereVisual Studio version Conversion Tool 1.1.

 

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.