浏览代码

添加驱动器容量大小工具

yuzhengyang 6 年之前
父节点
当前提交
081c10cf64

+ 2 - 26
Azylee.Utils/Azylee.Core/WindowsUtils/InfoUtils/ComputerInfoTool.cs

@@ -420,19 +420,7 @@ namespace Azylee.Core.WindowsUtils.InfoUtils
         /// <returns></returns>
         /// <returns></returns>
         public static long GetSystemDriveTotalSize()
         public static long GetSystemDriveTotalSize()
         {
         {
-            try
-            {
-                DriveInfo Drive = new DriveInfo("C");//系统盘驱动器
-                var osinfo = OsInfo();
-                if (osinfo != null)
-                {
-                    string drive = osinfo.Item2.Substring(0, 1);
-                    Drive = new DriveInfo(drive);
-                }
-                return Drive.TotalSize / 1024;
-            }
-            catch { }
-            return 0;
+            return DriveTool.GetSystemDriveTotalSize();
         }
         }
         /// <summary>
         /// <summary>
         /// 获取系统盘可用容量(单位:KB)
         /// 获取系统盘可用容量(单位:KB)
@@ -440,19 +428,7 @@ namespace Azylee.Core.WindowsUtils.InfoUtils
         /// <returns></returns>
         /// <returns></returns>
         public static long GetSystemDriveAvailableSize()
         public static long GetSystemDriveAvailableSize()
         {
         {
-            long size = 0;
-            try
-            {
-                var osinfo = OsInfo();
-                if (osinfo != null)
-                {
-                    string drive = osinfo.Item2.Substring(0, 1);
-                    DriveInfo Drive = new DriveInfo(drive);
-                    size = Drive.TotalFreeSpace / 1024;
-                }
-            }
-            catch { }
-            return size;
+            return DriveTool.GetSystemDriveAvailableSize();
         }
         }
         /// <summary>
         /// <summary>
         /// 获取磁盘上次格式化时间
         /// 获取磁盘上次格式化时间

+ 83 - 0
Azylee.Utils/Azylee.Core/WindowsUtils/InfoUtils/DriveTool.cs

@@ -0,0 +1,83 @@
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+
+namespace Azylee.Core.WindowsUtils.InfoUtils
+{
+    public static class DriveTool
+    {
+        /// <summary>
+        /// 获取系统盘总容量(单位:KB)
+        /// </summary>
+        /// <returns></returns>
+        public static long GetSystemDriveTotalSize()
+        {
+            try
+            {
+                DriveInfo Drive = new DriveInfo("C");//系统盘驱动器
+                var osinfo = ComputerInfoTool.OsInfo();
+                if (osinfo != null)
+                {
+                    string drive = osinfo.Item2.Substring(0, 1);
+                    Drive = new DriveInfo(drive);
+                }
+                return Drive.TotalSize / 1024;
+            }
+            catch { }
+            return 0;
+        }
+        /// <summary>
+        /// 获取磁盘总容量(单位:KB)
+        /// </summary>
+        /// <returns></returns>
+        public static long GetDriveTotalSize(string driveName)
+        {
+            try
+            {
+                string drive = driveName.Substring(0, 1);
+                DriveInfo Drive = new DriveInfo(drive);
+                return Drive.TotalSize / 1024;
+            }
+            catch { }
+            return 0;
+        }
+        /// <summary>
+        /// 获取系统盘可用容量(单位:KB)
+        /// </summary>
+        /// <returns></returns>
+        public static long GetSystemDriveAvailableSize()
+        {
+            long size = 0;
+            try
+            {
+                var osinfo = ComputerInfoTool.OsInfo();
+                if (osinfo != null)
+                {
+                    string drive = osinfo.Item2.Substring(0, 1);
+                    DriveInfo Drive = new DriveInfo(drive);
+                    size = Drive.TotalFreeSpace / 1024;
+                }
+            }
+            catch { }
+            return size;
+        }
+        /// <summary>
+        /// 获取磁盘可用容量(单位:KB)
+        /// </summary>
+        /// <returns></returns>
+        public static long GetDriveAvailableSize(string driveName)
+        {
+            long size = 0;
+            try
+            {
+                string drive = driveName.Substring(0, 1);
+                DriveInfo Drive = new DriveInfo(drive);
+                size = Drive.TotalFreeSpace / 1024;
+            }
+            catch { }
+            return size;
+        }
+    }
+}

二进制
AzyleeCC.Utils/.vs/AzyleeCC.Utils/v15/Server/sqlite3/storage.ide


+ 4 - 0
AzyleeCC.Utils/AzyleeCC.Core/AzyleeCC.Core.csproj

@@ -4,4 +4,8 @@
     <TargetFramework>netcoreapp2.0</TargetFramework>
     <TargetFramework>netcoreapp2.0</TargetFramework>
   </PropertyGroup>
   </PropertyGroup>
 
 
+  <ItemGroup>
+    <Folder Include="DrawingUtils\ImageUtils\" />
+  </ItemGroup>
+
 </Project>
 </Project>