C#检查硬盘容量

        public static long GetHardDiskFreeSpace(string str_HardDiskName) //磁盘号
        {   
            long freeSpace = new long(); 
            str_HardDiskName = str_HardDiskName + ":\\"; 
            System.IO.DriveInfo[] drives = System.IO.DriveInfo.GetDrives(); 
            foreach (System.IO.DriveInfo drive in drives) 
            { 
                if (drive.Name == str_HardDiskName) 
                { 
                    freeSpace = drive.TotalFreeSpace;//剩余容量
                    freeSpace = drive.TotalSize; //总容量
                } 
            } 
            return freeSpace; 
        }                        

 

C#检查硬盘容量

上一篇:win10关闭关闭更新 && Windows Defender--并不会关闭防火墙


下一篇:[.Net]windows获取开机时间和计时方法