vb.net - 如何在 vb.net 中以编程方式设置文件夹共享

标签 vb.net

我有客户端-服务器环境并开发了一个客户端-服务器项目。

我需要使用 VB.NET 以编程方式共享服务器计算机的文件夹

请帮助我。

最佳答案

这是one example它使用 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

关于vb.net - 如何在 vb.net 中以编程方式设置文件夹共享,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2543567/

相关文章:

sql-server - LINQ to SQL 对象版本控制

VB.NET:复选框列表:*after* ItemChecked

mysql - 使用Left Join时如何不在查询结果中包含ID

vb.net - 将 XML 文件加载到 VB.Net 结构中

c# - 使用 peek 或 read 读取一个 2GB 的文件

vb.net - 我做错了什么: Structure cannot be indexed because it has no default property (WITH CLAUSE)

vb.net - listView.SortKey = ColumnHeader.Index - 1

mysql - 如何使用 MySQL 将项目添加到列表框

c# - 如何将一个图形对象复制到另一个

vb.net - 读取 JSON 中的对象数组