Login or Sign Up
Logging in...
Remember me
Log in
Or
Sign Up
Forgot password or user name?
Log in with
Search in titles only
Search in C Sharp only
Search
Advanced Search
Forums
BYTES
Product Launch
Updates
Developer Toolkit
Today's Posts
Member List
Calendar
Home
Forum
Topic
C Sharp
How to check folder is shared or not?
Collapse
X
Collapse
Posts
Latest Activity
Photos
Page
of
1
Filter
Time
All Time
Today
Last Week
Last Month
Show
All
Discussions only
Photos only
Videos only
Links only
Polls only
Events only
Filtered by:
Clear All
new posts
Previous
template
Next
abhimusale
New Member
Join Date:
May 2010
Posts:
3
#1
How to check folder is shared or not?
May 4 '10, 11:45 AM
Using C# for an application in which I am working on, I need to check the
available folder is shared or not. How to check it?
Thanks!
Plater
Recognized Expert
Expert
Join Date:
Apr 2007
Posts:
7872
#2
May 4 '10, 05:02 PM
Well, you could use WMI?
I took this right from the WMI Code Creator(usefull little tool)
[code=C#]
using System;
using System.Manageme nt;
using System.Windows. Forms;
namespace WMISample
{
public class MyWMIQuery
{
public static void Main()
{
try
{
ManagementObjec tSearcher searcher =
new ManagementObjec tSearcher("root \\CIMV2",
"SELECT * FROM Win32_Share");
foreach (ManagementObje ct queryObj in searcher.Get())
{
Console.WriteLi ne("-----------------------------------");
Console.WriteLi ne("Win32_Shar e instance");
Console.WriteLi ne("-----------------------------------");
Console.WriteLi ne("AccessMask : {0}", queryObj["AccessMask "]);
Console.WriteLi ne("AllowMaximu m: {0}", queryObj["AllowMaxim um"]);
Console.WriteLi ne("Caption: {0}", queryObj["Caption"]);
Console.WriteLi ne("Description : {0}", queryObj["Descriptio n"]);
Console.WriteLi ne("InstallDate : {0}", queryObj["InstallDat e"]);
Console.WriteLi ne("MaximumAllo wed: {0}", queryObj["MaximumAllowed "]);
Console.WriteLi ne("Name: {0}", queryObj["Name"]);
Console.WriteLi ne("Path: {0}", queryObj["Path"]);
Console.WriteLi ne("Status: {0}", queryObj["Status"]);
Console.WriteLi ne("Type: {0}", queryObj["Type"]);
}
}
catch (ManagementExce ption e)
{
MessageBox.Show ("An error occurred while querying for WMI data: " + e.Message);
}
}
}
}
[/code]
Example output:
-----------------------------------
Win32_Share instance
-----------------------------------
AccessMask:
AllowMaximum: True
Caption: License
Description:
InstallDate:
MaximumAllowed:
Name: httproot
Path: C:\inetpub\wwwr oot\
Status: OK
Type: 0
So Name and Path are probably your most usefull properties
Comment
Post
Cancel
Previous
template
Next
Working...
Yes
No
OK
OK
Cancel
👍
👎
☕
Comment