• C#获取硬盘空间信息


            ///  <summary> 
            /// 获取指定驱动器的空间总大小(单位为B) 
            ///  </summary> 
            ///  <param name="str_HardDiskName">只需输入代表驱动器的字母即可 </param> 
            ///  <returns> </returns> 
            public static long GetHardDiskSpace(string str_HardDiskName) 
            { 
                long totalSize= 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) 
                    {
                        totalSize = drive.TotalSize / (1024 * 1024 * 1024); 
                    } 
                } 
                return totalSize; 
            }
    
            ///  <summary> 
            /// 获取指定驱动器的剩余空间总大小(单位为B) 
            ///  </summary> 
            ///  <param name="str_HardDiskName">只需输入代表驱动器的字母即可 </param> 
            ///  <returns> </returns> 
            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 / (1024 * 1024 * 1024); 
                    } 
                } 
                return freeSpace; 
            }
  • 相关阅读:
    Android_项目文件结构目录分析
    WPF_MVVM 开发的几种模式讨论
    Blend_技巧篇_淡入淡出
    Blend_技巧篇_导入PSD文件制作ToggleButton (Z)
    Blend_界面快速入门(Z)
    Blend_软件系列简介(Z)
    Blend_ControlTemplate(Z)
    803. 区间合并
    P4017 最大食物链计数
    P1113 杂务
  • 原文地址:https://www.cnblogs.com/dinotang/p/3272172.html
Copyright © 2020-2023  润新知