منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب
عمل مشاركة لفولدر - نسخة قابلة للطباعة

+- منتدى فيجوال بيسك لكل العرب | منتدى المبرمجين العرب (http://vb4arb.com/vb)
+-- قسم : قسم لغة الفيجوال بيسك VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=182)
+--- قسم : قسم مقالات VB.NET (http://vb4arb.com/vb/forumdisplay.php?fid=184)
+--- الموضوع : عمل مشاركة لفولدر (/showthread.php?tid=30037)



عمل مشاركة لفولدر - makky - 25-06-19

اول مرة انزل موضوع .انا بتعلم منكم طبعا كنت سئلت ازاي اعمل شير لفولدر بواسطة ال vb.net
كود :
Sub sharrd()
       Try

           Dim dInfo As New DirectoryInfo("D:\database")
           Dim dSecurity As DirectorySecurity = dInfo.GetAccessControl()
           dSecurity.AddAccessRule(New FileSystemAccessRule("everyone", FileSystemRights.FullControl, InheritanceFlags.ObjectInherit Or InheritanceFlags.ContainerInherit, PropagationFlags.InheritOnly, AccessControlType.Allow))
           dInfo.SetAccessControl(dSecurity)

           Dim managementClass As New ManagementClass("Win32_Share")
           Dim inParams As ManagementBaseObject = managementClass.GetMethodParameters("Create")

           inParams("Description") = "My Description"
           inParams("Name") = "$database$"
           inParams("Path") = "D:\database"
           inParams("Type") = &H0
           inParams("MaximumAllowed") = Nothing
           inParams("Password") = Nothing
           inParams("Access") = Nothing ' Make Everyone has full control access.

           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
       Catch ex As Exception
           MessageBox.Show(ex.Message)
       End Try