磁盘配额的wmi版本(C#)
时间:2022-07-31 17:55:17
using System;
using System.Management;
namespace DiskQuota
{
/// <summary>
/// Class1 的摘要说明。
/// </summary>
class Class1
{
/// <summary>
/// 应用程序的主入口点。
/// </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);
}
}
}
}
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
详解Android数据存储—使用SQLite数据库
![](https://img.aspxhome.com/file/2023/4/86744_0s.png)
Android AutoCompleteTextView控件基本用法示例
Android自定义View实现五子棋游戏
![](https://img.aspxhome.com/file/2023/5/126685_0s.jpg)
使用IntelliJ IDEA 配置安卓(Android)开发环境的教程详解(新手必看)
![](https://img.aspxhome.com/file/2023/9/130319_0s.png)
C语言非递归后序遍历二叉树
![](https://img.aspxhome.com/file/2023/9/124039_0s.jpg)
Java编程实现高斯模糊和图像的空间卷积详解
![](https://img.aspxhome.com/file/2023/6/90976_0s.png)
Spring Boot从Controller层进行单元测试的实现
使用Nexus搭建Maven私服教程的方法步骤
![](https://img.aspxhome.com/file/2023/3/66203_0s.jpg)
浅谈Async和Await如何简化异步编程(几个实例让你彻底明白)
![](https://img.aspxhome.com/file/2023/4/104284_0s.jpg)
Flutter WebView 预加载实现方法(Http Server)
一文让你搞懂如何手写一个redis分布式锁
Android利用Canvas类绘制图形
![](https://img.aspxhome.com/file/2023/5/113315_0s.jpg)
protobuf与json转换小结
Java中的传值与传引用实现过程解析
Java实战宠物店在线交易平台的实现流程
![](https://img.aspxhome.com/file/2023/4/119204_0s.png)
C# 爬虫简单教程
![](https://img.aspxhome.com/file/2023/0/72470_0s.png)
详谈java 堆区、方法区和栈区
C#实现让ListBox适应最大Item宽度的方法
C#操作XML文件实例汇总
Android中Canvas的常用方法总结
![](https://img.aspxhome.com/file/2023/1/111721_0s.png)