如何使用vb.net共享文件夹? [英] How to share a folder using vb.net?

查看:415
本文介绍了如何使用vb.net共享文件夹?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在运行时创建一个文件夹并授予其完全控制权,但是当我打开

高级共享标签时,我发现共享文件夹的权限是只读的。我怎么能使用Vb.Net?

I am creating a folder at runtime and giving its access to full control but when i open the
Advance Sharing Tab i found it that the permission for sharing the folder is Read only.How can i give the permission for sharing to everyone with FullControl using Vb.Net?

推荐答案

给予每个人使用FullControl共享的权限你需要一些WMI才能这样做。



它可以通过这种方式完成。您需要添加对System.Management的引用并导入System.Management和System.Management.Instrumentation命名空间

you would require some WMI to do this.

it can be done this way. You need to add a reference to System.Management and import the System.Management and System.Management.Instrumentation namespaces
Try
Dim managementClass As New ManagementClass("Win32_Share")
Dim inParams As ManagementBaseObject = managementClass.GetMethodParameters("Create")
inParams("Description") = "My Description"
inParams("Name") = "Share Name"
inParams("Path") = "C:\My Folder"
inParams("Type") = &H0
Dim outParams As ManagementBaseObject = managementClass.InvokeMethod("Create", inParams, Nothing)
If Convert.ToUInt32(outParams.Properties("ReturnValue").Value) <> 0 Then
MessageBox.Show("Unable to share directory.")
else
MessageBox.Show("Shared folder successfully!")
End If


这篇关于如何使用vb.net共享文件夹?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆