好像是vb的,要调用CreateObject函数需要引用什么程序集,那个命名空间,谢谢原帖地址
http://www.mikepoulson.com/code/quotafunctions.cs.txtpublic class DiskQuota
{
    public static int GetUsersQuotaLimit(string strServerName, string strDriveLetter, string strUserName)
    {        string strFunctionName = "GetUserQuotaLimit";
        //ex StrServerName = server1
        //ex strDriveLetter = c
        //ex strUsername = domain\bla        if (InStr(strServerName, "\\")!=0||InStr(strDriveLetter, ":")!=0)
            //Make sure we are sent the correct data
        {
            return -1;
        }        object objDiskQuotas; //object that will hold the connection to the disk
        object objUser; // Object that will hold the connection to the user on the disk
        try
        {
            objDiskQuotas = CreateObject("Microsoft.DiskQuota.1");
            objDiskQuotas.Initialize("\\\\"+strServerName+"\\"+strDriveLetter+"$\\\\", true);            objUser = objDiskQuotas.FindUser(strUserName);
            return objUser.QuotaLimit;
        }
        catch(Exception ex)
        {
           
            return -1;
        }        finally
        {
            objDiskQuotas = null;
            objUser = null;
        }    }
}

解决方案 »

  1.   

    CreateObject ? c#中没有这个,这个是vb的
      

  2.   

    <%@ 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{
    %>
      

  3.   

    DiskQuotaTypeLibrary 要引用DLL C:\WINDOWS\system32\dskquota.dll
      

  4.   

    DiskQuotaTypeLibrary 要引用DLL C:\WINDOWS\system32\dskquota.dll
      

  5.   

    我引用了C:\WINDOWS\system32\dskquota.dll
    也使用了DiskQuotaTypeLibrary 命名空间,可是还是不行呀。CreateObject还是报错
      

  6.   

    以前用过类似的,google了一下,可以参考参考
    ---------------------------------------------------------
    C#中类似 CreateObject 的方法就是 System.Activator.CreateInstance.  后续的对象函数的调用可以通过InvokeMember方法来实现。如在VB中的源代码如下:
    这种方式叫Late-Bind,关于早期绑定和后期绑定的区别见 http://msdn2.microsoft.com/zh-cn/library/0tcf61s1(VS.80).aspx
    Public Sub TestLateBind() 
            Dim o As Object = CreateObject("SomeClass") 
            o.SomeMethod(arg1, arg2) 
            w = o.SomeFunction(arg1, arg2) 
            w = o.SomeGet 
            o.SomeSet = w 
    End Sub 转换成C#的代码如下所示:public void TestLateBind() 

            System.Type oType = System.Type.GetTypeFromProgID("SomeClass"); 
            object o = System.Activator.CreateInstance(oType); 
            oType.InvokeMember("SomeMethod", System.Reflection.BindingFlags.InvokeMethod, null, o, new object[] {arg1, arg2});
            w = oType.InvokeMember("SomeFunction", System.Reflection.BindingFlags.InvokeMethod, null, o, new object[] {arg1, arg2});
            w = oType.InvokeMember("SomeGet", System.Reflection.BindingFlags.GetProperty, null, o, null); 
            oType.InvokeMember("SomeSet", System.Reflection.BindingFlags.SetProperty, null, o, new object[] {w}); 
    } 里面有方法,属性的调用设定,很简单。