打印本文 打印本文 关闭窗口 关闭窗口
VB.NET下通过WMI共享文件夹
作者:武汉SEO闵涛  文章来源:敏韬网  点击数3526  更新时间:2009/4/23 19:00:36  文章录入:mintao  责任编辑:mintao
Option Explicit On
Option Strict On

Imports System
Imports System.Collections
Imports System.ComponentModel
Imports System.Globalization
Imports System.Management

Namespace Edanmo.IO

    Public NotInheritable Class NetShare
        Implements IDisposable

        Private _share As ManagementObject

        Private Sub New(ByVal share As ManagementObject)
            _share = share
        End Sub

        '''''''''''' -----------------------------------------------------------------------------
        '''''''''''' <summary>
        '''''''''''' Gets the share access rights for the current user or group.
        '''''''''''' </summary>
        '''''''''''' <history>
        '''''''''''' [Eduardo Morcillo] 11/08/2004 Created
        '''''''''''' </history>
        '''''''''''' -----------------------------------------------------------------------------
        Public ReadOnly Property AccessMask() As AccessMasks
            Get
                Return CType(Convert.ToInt32(_share.InvokeMethod("GetAccessMask", Nothing), CultureInfo.InvariantCulture), AccessMasks)
            End Get
        End Property

        '''''''''''' -----------------------------------------------------------------------------
        '''''''''''' <summary>
        '''''''''''' Gets or sets the maximum number of user connections.
        '''''''''''' </summary>
        '''''''''''' <history>
        '''''''''''' [Eduardo Morcillo] 11/08/2004 Created
        '''''''''''' </history>
        '''''''''''' -----------------------------------------------------------------------------
        Public Property AllowMaximum() As Integer
            Get
                Return Convert.ToInt32(_share.GetPropertyValue("AllowMaximum"), CultureInfo.InvariantCulture)
            End Get
            Set(ByVal value As Integer)
                Me.SetShareInfo(value, Me.Description, Nothing)
            End Set
        End Property

        '''''''''''' -----------------------------------------------------------------------------
        '''''''''''' <summary>
        '''''''''''' Gets the share description.
        '''''''''''' </summary>
        '''''''''''' <history>
        '''''''''''' [Eduardo Morcillo] 11/08/2004 Created
        '''''''''''' </history>
        '''''''''''' -----------------------------------------------------------------------------
        Public Property Description() As String
            Get
                Return _share.GetPropertyValue("Description").ToString
            End Get
            Set(ByVal value As String)
                Me.SetShareInfo(Me.MaximumAllowed, value, Nothing)
            End Set
        End Property

        '''''''''''' -----------------------------------------------------------------------------
        '''''''''''' <summary>
        '''''''''''' Gets
        '''''''''''' </summary>
        '''''''''''' <history>
        '''''''''''' [Eduardo Morcillo] 11/08/2004 Created
        '''''''''''' </history>
        '''''''''''' -----------------------------------------------------------------------------
        Public Property MaximumAllowed() As Integer
            Get
                Return Convert.ToInt32(_share.GetPropertyValue("MaximumAllowed"), CultureInfo.InvariantCulture)
            End Get
            Set(ByVal value As Integer)
                Me.SetShareInfo(value, Me.Description, Nothing)
            End Set
        End Property

        '''''''''''' -----------------------------------------------------------------------------
        '''''''''''' <summary>
        '''''''''''' Gets the share name.
        '''''''''''' </summary>
        '''''''''''' <history>
        '''''''''''' [Eduardo Morcillo] 11/08/2004 Created
        '''''''''''' </history>
        '''''''''''' -----------------------------------------------------------------------------
        Public ReadOnly Property Name() As String
            Get
                Return _share.GetPropertyValue("Name").ToString
            End Get
        End Property

        '''''''''''' -----------------------------------------------------------------------------
        '''''''''''' <summary>
        '''''''''''' Gets the local path of the share.
        '''''''''''' </summary>
        '''''''''''' <history>
        '''''''''''' [Eduardo Morcillo] 11/08/2004 Created
        '''''''''''' </history>
        '''''''''''' -----------------------------------------------------------------------------
        Public ReadOnly Property Path() As String
            Get
                Return _share.GetPropertyValue("Path").ToString
            End Get
        End Property

        '''''''''''' -----------------------------------------------------------------------------
        '''''''''''' <summary>
        '''''''''''' Gets the share status.
        '''''''''''' </summary>
        '''''''''''' <history>
        '''''''''''' [Eduardo Morcillo] 11/08/2004 Created
        '''''''''''' </history>
        '''''''''''' -----------------------------------------------------------------------------
        Public ReadOnly Property Status() As String
        &n

[1] [2] [3] [4]  下一页

打印本文 打印本文 关闭窗口 关闭窗口