C#文件夹共享
来源:互联网 发布:淘宝如何设置收藏有礼 编辑:程序博客网 时间:2024/05/07 02:43
using System;
using System.Management;
class CreateShare
{
public static void Main(string[] args)
{
ManagementClass _class = new ManagementClass(new ManagementPath("Win32_Share"));
object[] obj = {"C://Temp","我的共享",0,10,"Dot Net 实现的共享",""};
_class.InvokeMethod("create",obj);
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////
//设置共享的方法
using System;
using System.Management;
using System.Windows.Forms;
namespace WMISample
{
public class CallWMIMethod
{
public static void Main()
{
try
{
ManagementClass classInstance =
new ManagementClass( "root//CIMV2 ", "Win32_Share ", null);
// Obtain in-parameters for the method
ManagementBaseObject inParams =
classInstance.GetMethodParameters( "Create ");
// Add the input parameters.
inParams[ "Name "] = "share name ";
inParams[ "Path "] = "D://新建文件夹 ";
inParams[ "Type "] = 0;
// Execute the method and obtain the return values.
ManagementBaseObject outParams =
classInstance.InvokeMethod( "Create ", inParams, 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);
}
}
}
}
//////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
删除共享的方法:
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);
}
}
}
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////////
//设置共享的方法
using System;
using System.Management;
using System.Windows.Forms;
namespace WMISample
{
public class CallWMIMethod
{
public static void Main()
{
try
{
ManagementClass classInstance =
new ManagementClass("root//CIMV2", "Win32_Share", null);
// Obtain in-parameters for the method
ManagementBaseObject inParams =
classInstance.GetMethodParameters("Create");
// Add the input parameters.
inParams["Name"] = "share name";
inParams["Path"] = "D://新建文件夹";
inParams["Type"] = 0;
// Execute the method and obtain the return values.
ManagementBaseObject outParams =
classInstance.InvokeMethod("Create", inParams, 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);
}
}
}
}
- C#文件夹共享
- C#共享文件夹
- C#读写共享文件夹
- C# ManagementClass 文件夹共享
- C#读写共享文件夹
- C# 访问网络共享文件夹
- C#连接服务器共享文件夹
- C#读写远程共享文件夹
- C#中设置windows共享文件夹
- C# 实现访问网络共享文件夹
- C#设置和取消文件夹共享
- C#共享文件夹文件包含共享用户及密码
- 共享文件夹
- C#如何访问远程计算机的共享文件夹
- C#向共享文件夹上传及下载文件
- C# 访问共享文件夹或者磁盘(需要用户名密码)
- C# 访问共享文件夹或者磁盘(需要用户名密码)
- C# 访问共享文件夹或者磁盘(需要用户名密码)
- ASP.NET 去除HTML标记 函数
- linux下C语言创建多级目录
- windows 2003 server密码恢复
- Windows PowerShell 2.0 CTP 下载
- wow物品分类
- C#文件夹共享
- 内存泄漏
- lang属性值
- blog搬家啦
- ffmpeg安装攻略
- ffmpeg参数设置
- 用Apache Jakarta的common-net包写的访问FTP的程式
- 巧妙使用移动硬盘
- 配置VSS(源代码管理器)