如何获得的未分配空间信息在物理磁盘 [英] How to get unallocated space info in a physical disk

查看:695
本文介绍了如何获得的未分配空间信息在物理磁盘的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

任何人可以帮助,如何使用C#获取的未分配空间信息在磁盘?

Can anybody help, how to get unallocated space information in a disk using C# ?

推荐答案

如果你想知道的对于一个体积总量的可用空间,可以使用 DriveInfo.AvailableFreeSpace

If you want to know the total free space for a volume, you can use DriveInfo.AvailableFreeSpace.

http://msdn.microsoft.com/en-us/library/system.io.driveinfo.aspx

您还可以使用WMI来获取磁盘上的有关分区的信息,使用 Win32_DiskPartition Win32_DiskDrive

You can also use WMI to fetch information about partitions on the disk, using Win32_DiskPartition and Win32_DiskDrive:

Win32_DiskPartition:的 http://msdn.microsoft.com/en-us/library/aa394135%28VS.85%29.aspx

Win32_DiskDrive:的http:// msdn.microsoft.com/en-us/library/aa394132%28v=VS.85%29.aspx

Win32_DiskPartition: http://msdn.microsoft.com/en-us/library/aa394135%28VS.85%29.aspx
Win32_DiskDrive: http://msdn.microsoft.com/en-us/library/aa394132%28v=VS.85%29.aspx

您可以使用的DeviceID 字段,以确定哪个分区是硬盘上,然后使用 StartOffset 尺寸字段在地图上标注的parititions是物理磁盘上的位置。然后,只需使用来自 Win32_DiskDrive 数据制定出整个磁盘大小,并计算出剩余部分。

You can use the DeviceID field to identify which partition is on which disk, then use the StartOffset and Size fields to build a map of where the parititions are on the physical disk. Then just use the data from Win32_DiskDrive to work out the whole disk size, and compute the remainder.

下面是一个文章MSDN上,应该给你所有你在使用WMI需要的帮助:

http://msdn.microsoft.com/en-us/library/ms257338.aspx

Here's an article on MSDN that should give you all the help you need in using WMI:
http://msdn.microsoft.com/en-us/library/ms257338.aspx

这篇关于如何获得的未分配空间信息在物理磁盘的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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