用asp或asp.net显示NTFS磁盘空间

    技术2022-05-11  98

    ASP的:

    <%disk=request.QueryString("disk")user=request.QueryString("user")if disk="" or user="" thenResponse.Write "没有指定硬盘或用户(disk,user)"else

    Set colDiskQuotas = CreateObject("Microsoft.DiskQuota.1")colDiskQuotas.Initialize disk, Trueset objUser = colDiskQuotas.FindUser(user)Response.write "警告等级:"Response.write objUser.QuotaThresholdResponse.write "<p>配额限制:"Response.write objUser.QuotaLimit Response.write "<p>使用数量:"Response.write objUser.QuotaUsedResponse.write "<p>状态:"Response.write colDiskQuotas.QuotaState

    end if%>

     

    ASP.NET的:

    <%@ Page language="c#" aspcompat="true" AutoEventWireup="false" %><%@ Import Namespace= "DiskQuotaTypeLibrary"%>

    <% string disk = Request.Params("disk"); stirng user = Request.Params("user");  if (disk==null || user==null){  Response.Wirte("没有输入盘或用户名(disk,user).");  return; }

    try{ DiskQuotaControlClass diskQuotaControl = new DiskQuotaControlClass(); //Initializes the control to the specified path diskQuotaControl.Initialize ("f://", true); DIDiskQuotaUser dskuser = diskQuotaControl.FindUser("staff"); Response.Write("磁盘配额:" +dskuser.QuotaLimitText + "<br>"); Response.Write("警告容量:" + dskuser.QuotaThresholdText + "<br>"); Response.Write("已用容量:" + dskuser.QuotaUsedText + "<br>");  Response.Write("状态:" + dskuser.AccountStatus + "<br>"); Response.Write( "用户名:" + dskuser.LogonName);}catch{%> 


    最新回复(0)