我的任务是将本地电脑上的文件夹共享到我的网络,但仅限于同一个域用户。
这是我的代码到目前为止,但我无法看到我可以在哪里添加共享权限?
Public Class URNScanning
Private Const URN_SCANNED = "URN_Scanned"
Private Const URN_SCANNED_NAME = "URN_Scanned"
Private Const URN_SCANNED_DESCRIPTION = "URN_Scanned_Files"
Public Shared Sub ShareFolder()
Dim sharedPath As String = Path.Combine(Application.StartupPath, URN_SCANNED)
If Not (Directory.Exists(sharedPath)) Then
Directory.CreateDirectory(sharedPath)
End If
Dim managementClass As New ManagementClass("Win32_Share")
Dim inParams As ManagementBaseObject = managementClass.GetMethodParameters("Create")
inParams.Item("Description") = URN_SCANNED_DESCRIPTION
inParams.Item("Name") = URN_SCANNED_NAME
inParams.Item("Path") = sharedPath
inParams.Item("Type") = 0
If (DirectCast(managementClass.InvokeMethod("Create", inParams, Nothing).Properties.Item("ReturnValue").Value, UInt32) <> 0) Then
Throw New Exception("Unable to share directory.")
End If
End Sub
结束班