我使用此代码共享文件夹:
Public Sub Share()
Dim managementClass As New ManagementClass("Win32_Share")
Dim inParams As ManagementBaseObject = managementClass.GetMethodParameters("Create")
inParams("Description") = "My Description"
inParams("Name") = "Share Name"
inParams("Path") = "D:\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.")
MessageBox.Show("Shared folder successfully!")
End
Sub
Run Code Online (Sandbox Code Playgroud)
现在我想要的是定义可以通过网络访问该文件夹的用户?我怎么能这样做?
谢谢!
我试图在图片框中显示图像.该应用程序有两部分.第一部分是Windows应用程序,第二部分是Web服务(asmx).
这是Windows应用程序的代码:
Public Sub PrikazSlike()
Dim p As localhost.Service1 = New localhost.Service1()
PictureBox1.Image = Image.FromStream(p.PictureShow())
End Sub
Run Code Online (Sandbox Code Playgroud)
这是Web服务的代码:
Imports System.Web.Services
Imports System.Web.Services.Protocols
Imports System.ComponentModel
Imports System.IO
' To allow this Web Service to be called from script, using ASP.NET AJAX, uncomment the following line.
' <System.Web.Script.Services.ScriptService()> _
<System.Web.Services.WebService(Namespace:="http://tempuri.org/")> _
<System.Web.Services.WebServiceBinding(ConformsTo:=WsiProfiles.BasicProfile1_1)> _
<ToolboxItem(False)> _
Public Class Service1
Inherits System.Web.Services.WebService
<WebMethod()> _
Public Function PictureShow() As System.IO.MemoryStream
Dim client As New System.Net.WebClient()
Dim stream1 As New System.IO.MemoryStream()
Dim data As Byte() = …Run Code Online (Sandbox Code Playgroud)