C# 将一个文件设为共享
发布网友
发布时间:2024-10-02 01:08
我来回答
共2个回答
热心网友
时间:2024-10-19 13:58
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= 'Temp ' ",
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);
}
}
}
}
试过了 这个是好用的昂
热心网友
时间:2024-10-19 14:01
这里就是http://blog.csdn.net/wenshengwang/archive/2007/11/06/1869989.aspx