我在程序中用NetShareAdd共享了一个文件夹,现在想在程序执行完以后取消对他的共享应该怎么做?
我想用NetShareDel(null,ref path,0);取消共享,可是不能完成功能?
(注:path是用NetShareAdd共享的文件夹的名字),朋友们帮忙看看是怎么回事?谢谢了
我想用NetShareDel(null,ref path,0);取消共享,可是不能完成功能?
(注:path是用NetShareAdd共享的文件夹的名字),朋友们帮忙看看是怎么回事?谢谢了
调试欢乐多
using System;
using System.Management;
using System.Windows.Forms;namespace WMISample
{
public class CallWMIMethod
{
public static void Main()
{
try
{
ManagementObject classInstance =
new ManagementObject("root\\CIMV2",
"Win32_Share.Name='共享名称'",
null); // no method in-parameters to define
// Execute the method and obtain the return values.
ManagementBaseObject outParams =
classInstance.InvokeMethod("Delete", null, null); // List outParams
Console.WriteLine("Out parameters:");
Console.WriteLine("ReturnValue: " + outParams["ReturnValue"]);
}
catch(ManagementException err)
{
MessageBox.Show("An error occurred while trying to execute the WMI method: " + err.Message);
}
}
}
}
老大,我的没有这个命名空间,没办法啊
谢谢了,终于找到这个命名空间了
试试jinta2001() 的方法,