识别90%占用的磁盘空间 [英] Identify disk space 90 % occupied
本文介绍了识别90%占用的磁盘空间的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何识别90%的磁盘空间在asp.net中被占用并放入一个msg框进行清理。请帮助
解决方案
这将为您提供可用空间百分比:
Console.WriteLine(GetFreePercentage( @ C:\跨度>));
...
private double GetFreePercentage(字符串 driveName)
{
foreach (DriveInfo drive in DriveInfo.GetDrives())
{
if (drive.IsReady&& drive.Name == driveName)
{
return (( double )drive.AvailableFreeSpace /( double )drive.TotalSize)* 100 ;
}
}
返回 -1。 0 ;
}当你需要知道时,你只需要打电话...
它可以帮助你确定..
driveinfo [ ^ ]
你可以使用DriveInfo类来获取所有驱动器。然后检查AvailableFreeSpace属性以获取每个驱动器的可用空间。 TotalSize属性获取每个驱动器的总大小。
一旦获得驱动器信息,您就可以计算应用程序中的百分比。
参考此链接
http://stackoverflow.com/questions/3210010/如何计算免费磁盘空间
http://stackoverflow.com/questions/1393711/c-sharp-get-free-disk-space
how to identify that 90 % of disk space is occupied in asp.net and put a msg box for cleanup.Please help
解决方案
This will give you the free space percentage:
Console.WriteLine(GetFreePercentage(@"C:\")); ... private double GetFreePercentage(string driveName) { foreach (DriveInfo drive in DriveInfo.GetDrives()) { if (drive.IsReady && drive.Name == driveName) { return ((double)drive.AvailableFreeSpace / (double)drive.TotalSize) * 100; } } return -1.0; }All you have to do is call it when you need to know...
it can help you for sure..
driveinfo[^]
You can use DriveInfo class to get all drive. Then check AvailableFreeSpace property to get available space for each drive & TotalSize property to get total size of each drive.
You can calculate percentage in your application once you get drive info.
Refer this link
http://stackoverflow.com/questions/3210010/how-to-calculate-free-disk-space
http://stackoverflow.com/questions/1393711/c-sharp-get-free-disk-space
这篇关于识别90%占用的磁盘空间的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文