磁盤(pán)配額的wmi版本(C#)
更新時(shí)間:2007年03月09日 00:00:00 作者:
using System;
using System.Management;
namespace DiskQuota
{
/// <summary>
/// Class1 的摘要說(shuō)明。
/// </summary>
class Class1
{
/// <summary>
/// 應(yīng)用程序的主入口點(diǎn)。
/// </summary>
[STAThread]
static void Main(string[] args)
{
try
{
ManagementClass c = new ManagementClass("Win32_DiskQuota");
ManagementObject quota = c.CreateInstance();
quota["Limit"] = 400000000;
quota["WarningLimit"] = 200000000;
// Get user account object
ManagementObject account = new
ManagementObject("Win32_Account.Domain=TODAY20040216,Name=ASPNET");
account.Get();
// get disk object
ManagementObject disk = new
ManagementObject("Win32_LogicalDisk.DeviceId='F:'");
disk.Get();
quota["QuotaVolume"] = disk;
quota["User"] = account;
quota.Put(); // commit
ManagementClass c = new ManagementClass("Win32_DiskQuota");
Console.WriteLine(c.SystemProperties);
foreach (ManagementObject o in c.GetInstances())
Console.WriteLine("Next : {0}", o.Path);
}
catch(Exception e)
{
Console.WriteLine("error:" + e);
}
}
}
}
using System.Management;
namespace DiskQuota
{
/// <summary>
/// Class1 的摘要說(shuō)明。
/// </summary>
class Class1
{
/// <summary>
/// 應(yīng)用程序的主入口點(diǎn)。
/// </summary>
[STAThread]
static void Main(string[] args)
{
try
{
ManagementClass c = new ManagementClass("Win32_DiskQuota");
ManagementObject quota = c.CreateInstance();
quota["Limit"] = 400000000;
quota["WarningLimit"] = 200000000;
// Get user account object
ManagementObject account = new
ManagementObject("Win32_Account.Domain=TODAY20040216,Name=ASPNET");
account.Get();
// get disk object
ManagementObject disk = new
ManagementObject("Win32_LogicalDisk.DeviceId='F:'");
disk.Get();
quota["QuotaVolume"] = disk;
quota["User"] = account;
quota.Put(); // commit
ManagementClass c = new ManagementClass("Win32_DiskQuota");
Console.WriteLine(c.SystemProperties);
foreach (ManagementObject o in c.GetInstances())
Console.WriteLine("Next : {0}", o.Path);
}
catch(Exception e)
{
Console.WriteLine("error:" + e);
}
}
}
}
相關(guān)文章
C# winform點(diǎn)擊生成二維碼實(shí)例代碼
這篇文章主要介紹了 C# winform點(diǎn)擊生成二維碼實(shí)例代碼,需要的朋友可以參考下2017-04-04
淺拷貝和深拷貝深入理解(shallow copy VS deep copy)
淺拷貝和深拷貝深入理解(shallow copy VS deep copy) 本文重點(diǎn)討論引用類(lèi)型變量的拷貝機(jī)制和實(shí)現(xiàn)2014-01-01
基于C#實(shí)現(xiàn)圖片滑動(dòng)驗(yàn)證碼的示例代碼
這篇文章主要為大家介紹了如何利用C#語(yǔ)言制作一個(gè)圖片滑動(dòng)驗(yàn)證碼,文中的示例代碼講解詳細(xì),感興趣的小伙伴可以了解一下2022-04-04
C#使用StopWatch獲取程序毫秒級(jí)執(zhí)行時(shí)間的方法
這篇文章主要介紹了C#使用StopWatch獲取程序毫秒級(jí)執(zhí)行時(shí)間的方法,涉及C#操作時(shí)間的相關(guān)技巧,需要的朋友可以參考下2015-04-04
RegexOptions.IgnoreCase正則表達(dá)式替換,忽略大小寫(xiě)
RegexOptions.IgnoreCase正則表達(dá)式替換,忽略大小寫(xiě),需要的朋友可以參考一下2013-03-03
C#實(shí)現(xiàn)獲取電腦中的端口號(hào)和硬件信息
這篇文章主要為大家詳細(xì)介紹了C#實(shí)現(xiàn)獲取電腦中的端口號(hào)和硬件信息的相關(guān)方法,文中的示例代碼講解詳細(xì),有需要的小伙伴可以參考一下2025-01-01

