磁盘配额,通过ManagementClass("Win32_DiskQuota")
2021-03-15 03:33
标签:ace sed format int system generic warning span domain C# 磁盘配额,通过ManagementClass("Win32_DiskQuota") 标签:ace sed format int system generic warning span domain 原文地址:https://www.cnblogs.com/xiangxisheng/p/12445005.htmlusing System;
using System.Collections.Generic;
using System.Management;
namespace ConsoleApp2
{
class Win32DiskQuota
{
private static readonly ManagementClass Win32_DiskQuota = new ManagementClass("Win32_DiskQuota");
internal class DiskQuota
{
private readonly string split_sign_1 = "\",Name=\"";
private readonly string split_sign_2 = "Win32_Account.Domain=\"";
private readonly string split_sign_3 = "Win32_LogicalDisk.DeviceID=\"";
internal long DiskSpaceUsed { get; }
internal long Limit { get; }
internal string QuotaVolume { get; }
internal int Status { get; }
internal string User { get; }
internal long WarningLimit { get; }
internal string Username { get; }
internal string Domain { get; }
internal string DeviceID { get; }
internal string Line { get; }
internal DiskQuota(PropertyDataCollection oProperties)
{
DiskSpaceUsed = Convert.ToInt64(oProperties["DiskSpaceUsed"].Value);
Limit = Convert.ToInt64(oProperties["Limit"].Value);
QuotaVolume = oProperties["QuotaVolume"].Value.ToString();
Status = Convert.ToInt32(oProperties["Status"].Value);
User = oProperties["User"].Value.ToString();
WarningLimit = Convert.ToInt64(oProperties["WarningLimit"].Value);
{
int i = User.IndexOf(split_sign_1);
if (i >= 0)
{
int pos = i + split_sign_1.Length;
Username = User.Substring(pos, User.Length - pos - 1);
int len1 = split_sign_2.Length;
Domain = User.Substring(len1, i - len1);
}
}
{
int i = QuotaVolume.IndexOf(split_sign_3);
if (i == 0)
{
int len1 = split_sign_3.Length;
DeviceID = QuotaVolume.Substring(len1, QuotaVolume.Length - len1 - 1);
}
}
Line = string.Format("{0} {1}\\{2} {3}/{4}", DeviceID, Domain, Username, DiskSpaceUsed, Limit);
}
}
internal static List
文章标题:磁盘配额,通过ManagementClass("Win32_DiskQuota")
文章链接:http://soscw.com/index.php/essay/64794.html