How to check folder is shared or not?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • abhimusale
    New Member
    • May 2010
    • 3

    How to check folder is shared or not?

    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
    • Apr 2007
    • 7872

    #2
    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

    Working...