我有Client-Server环境并为Client-Server开发了一个项目.
我需要使用VB.NET以编程方式共享我的Server机器的文件夹
请帮我.
这是一个使用ManagmentClass显示概念的示例.它是C#但可以轻松转换为VB.NET:
更新:
Directory.CreateDirectory("C:\MyTestShare")
Dim managementClass As New ManagementClass("Win32_Share")
Dim inParams As ManagementBaseObject = managementClass.GetMethodParameters("Create")
inParams.Item("Description") = "My Files Share"
inParams.Item("Name") = "My Files Share"
inParams.Item("Path") = "C:\MyTestShare"
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
Run Code Online (Sandbox Code Playgroud)