软件开发|编程技术|编程代码|编程入门先学什么—程序设计语言

磁盘配额的wmi版本(C#)

usingSystem;
usingSystem.Management;
namespaceDiskQuota
{
///<summary>
///Class1的摘要说明。
///</summary>
classClass1
{
///<summary>
///应用程序的主入口点。
///</summary>
[STAThread]
staticvoidMain(string[]args)
{
try
{
ManagementClassc=newManagementClass("Win32_DiskQuota");
ManagementObjectquota=c.CreateInstance();
quota["Limit"]=400000000;
quota["WarningLimit"]=200000000;
//Getuseraccountobject
ManagementObjectaccount=new
ManagementObject("Win32_Account.Domain=TODAY20040216,Name=ASPNET");
account.Get();
//getdiskobject
ManagementObjectdisk=new
ManagementObject("Win32_LogicalDisk.DeviceId='F:'");
disk.Get();
quota["QuotaVolume"]=disk;
quota["User"]=account;
quota.Put();//commit
ManagementClassc=newManagementClass("Win32_DiskQuota");
Console.WriteLine(c.SystemProperties);
foreach(ManagementObjectoinc.GetInstances())
Console.WriteLine("Next:{0}",o.Path);
}
catch(Exceptione)
{
Console.WriteLine("error:"+e);
}
}
}
}