XML数据
 <item>
    <IP></IP>                                          <!--IP地址-->
    <Username></Username>                              <!--用户名-->
    <Password></Password>                              <!--密码-->
    <driver></driver>                                  <!--磁盘-->
    <minsize></minsize>                                <!--磁盘最小空间警戒-->
    <leftsize></leftsize>
    </item>
 private double CheckDist(string IP, string username, string password, string driver)
    {
        long mb = 1048576;
        //1024x1024
        //设定生成的WMI所需的所有设置
        ConnectionOptions Conn = new ConnectionOptions();
        //设定用于WMI连接操作的用户名
        Conn.Username = username;
        //设定用户的口令
        Conn.Password = password;
        //设定用于执行WMI操作的范围
        ManagementScope Ms = new ManagementScope("\\\\"+IP +"\\root\\cimv2", Conn);
        try
        {
            //连接到实际操作的WMI范围
            Ms.Connect();
            //设定通过WMI要查询的内容
            ObjectQuery Query = new ObjectQuery("select FreeSpace ,Size ,Name from Win32_LogicalDisk where DriveType=3");
            //WQL语句,设定的WMI查询内容和WMI的操作范围,检索WMI对象集合
            ManagementObjectSearcher Searcher = new ManagementObjectSearcher(Ms, Query);
            //异步调用WMI查询
            ManagementObjectCollection ReturnCollection = Searcher.Get();
            double free = 0;
            double use = 0;
            double total = 0;
           
            //通过对产生的WMI的实例集合进行检索,获得硬盘信息
            foreach (ManagementObject Return in ReturnCollection)
            {                //Listbox1.Items.Add("磁盘名称:" + Return["Name"].ToString());
                //获得硬盘的可用空间
                free = Convert.ToInt64(Return["FreeSpace"]) / mb;
                //获得硬盘的已用空间
                use = (Convert.ToInt64(Return["Size"]) - Convert.ToInt64(Return["FreeSpace"])) / mb;
                //获得硬盘的合计空间
                total = Convert.ToInt64(Return["Size"]) / mb;                if (Return["Name"].ToString() == driver)
                {
                    return free;
                }            }
            return 0;
        }
        catch (Exception ee)
        {
            return 0;
        }
    }
从XML配置好 然后查询其他机器的磁盘空间 比如我访问A 可以           A访问我 失败 (错误)Windows Management Instrumentation 服务开启
Windows Management and Instrumentation 组件配置一样错误:
诊断到错误 拒绝访问。 (异常来自 HRESULT:0x80070005 (E_ACCESSDENIED))各位遇到类似问题的帮帮忙啊!!!谢谢谢谢!!