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.