标签:logic save result get lse select ica else tin
public static bool GetDiskInfo() { if (false == strCheckFreeSpace.Equals("1")) return true; try { //获得盘符HARDDISK var index = strSaveFolder.Trim().IndexOf(‘:‘); var HARDDISK = strSaveFolder.Trim().Substring(0, index + 1); SelectQuery selectQuery = new SelectQuery("select * from win32_logicaldisk"); ManagementObjectSearcher searcher = new ManagementObjectSearcher(selectQuery); ManagementObjectCollection diskcollection = searcher.Get(); if (diskcollection != null && diskcollection.Count > 0) { foreach (ManagementObject item in searcher.Get()) { int nType = Convert.ToInt32(item["DriveType"]); if (nType != Convert.ToInt32(DriveType.Fixed)) { continue; } else { if (item["DeviceID"].ToString().ToUpper() == HARDDISK) { double bytes = Convert.ToDouble(item["FreeSpace"]); var result = bytes / Math.Pow(1024, 3); if (result < Int32.Parse(你想要规定的gb数)) { return false; } } } } } } catch (Exception) { return false; } return true; }
标签:logic save result get lse select ica else tin
原文地址:https://www.cnblogs.com/zmy2020/p/12935118.html