以编程方式确定从UNC路径可用空间 [英] Programmatically determining space available from UNC Path

查看:295
本文介绍了以编程方式确定从UNC路径可用空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否有确定的UNC路径上的NAS sotrage可用空间的编程API?我看了看通过WMI文档,它是不明确的,这是可能的。

Is there a programmatic API for determining available space on NAS sotrage from a UNC path? I looked through the WMI documentation and it wasn't clear that this is possible.

一个code的例子和参考相关API调用将是非常美联社preciated。

A code example and references to the relevant API calls would be much appreciated.

推荐答案

使用这个例子的如何获得UNC路径,你可以只返回了自由空间的财产,我已经修改了code如下:

Using this example on how to get the UNC path, you could just return the FreeSpace property, I've modified the code below:

ManagementPath path = new ManagementPath(@"\" + System.Environment.MachineName + @"\root\cimv2");
ObjectQuery query = new ObjectQuery("select * from Win32_LogicalDisk WHERE DriveType = 4");
ManagementScope scope = new ManagementScope(path, new ConnectionOptions());
ManagementObjectSearcher search = new ManagementObjectSearcher(scope, query);

foreach (ManagementObject o in search.Get())
{
    Console.WriteLine(o.Properties["FreeSpace"].Value.ToString());
}

这篇关于以编程方式确定从UNC路径可用空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆