471,327 Members | 2,718 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,327 software developers and data experts.

Share folder.

Hi All ,
Is there a way to determine whether a folder is being shared with c# ?

Thanks , Itay.

Jan 24 '06 #1
1 1567
Hi,
"Itay" <it***@nur.com> wrote in message
news:11**********************@z14g2000cwz.googlegr oups.com...
Hi All ,
Is there a way to determine whether a folder is being shared with c# ?


Piece of code ( credit to Willy Denoyette)

using(ManagementClass exportedShares = new
ManagementClass("Win32_Share" ))
using(ManagementClass computer = new
ManagementClass("Win32_computersystem" ))
{
string localSystem = null;
ManagementObjectCollection localComputer = computer.GetInstances();
foreach(ManagementObject mo in localComputer)
{
localSystem = mo["Name"].ToString();
}
ManagementObjectCollection shares = exportedShares.GetInstances();
foreach(ManagementObject share in shares)
// dump UNC path
Console.WriteLine(@"UNC path \\{0}\{1}", localSystem, share["Name"]);
}

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
Jan 24 '06 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by brian.oneil2 | last post: by
4 posts views Thread by | last post: by
3 posts views Thread by Michel Smit | last post: by
2 posts views Thread by RN1 | last post: by

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.