首页 > 编程语言 >C# 获取磁盘信息

C# 获取磁盘信息

时间:2024-03-24 09:14:16浏览次数:26  
标签:1024 Console C# 获取 driveInfo WriteLine 磁盘 DriveInfo

namespace ConsoleApp_DriveInfo
{
    internal class Program
    {
        static void Main(string[] args)
        {
            Driveinfo();
        }

        static void Driveinfo()
        {

            DriveInfo driveInfo = new DriveInfo("d:/");
            

            // [ 属性 ]
            Console.WriteLine(driveInfo.DriveType);  // 获取磁盘类型
            Console.WriteLine(driveInfo.Name);       // 磁盘盘符
            Console.WriteLine(driveInfo.VolumeLabel);   // 磁盘名称
            Console.WriteLine(((driveInfo.TotalSize/1024)/1024)/1024+"GB");         // 获取磁盘总容量
            Console.WriteLine(((driveInfo.TotalFreeSpace/1024)/1024)/1024+"GB");    // 获取磁盘可用空间            
            Console.WriteLine(driveInfo.DriveFormat);       // 磁盘格式

            foreach (var x in DriveInfo.GetDrives()) { Console.WriteLine(x); }  // 获取所有盘符
        }

    }
}

 

标签:1024,Console,C#,获取,driveInfo,WriteLine,磁盘,DriveInfo
From: https://www.cnblogs.com/xs-xs/p/18092059

相关文章

  • C# 文件读写 IO.FileInfo
    ///参考链接https://learn.microsoft.com/zh-cn/dotnet/api/system.io.fileinfo?view=net-8.0//需要直到的是fileinfo主要用于查看文件信息,搭配FileStream或StreamWrite可以操作文件IO,FileStream需要实例化,可以接受fileinfo的对象usingMicrosoft.VisualBasic;us......
  • C# 文件监视 FileSystemWatcher
    //官方帮助Console:https://learn.microsoft.com/zh-cn/dotnet/api/system.io.filesystemwatcher?view=net-8.0//官方帮助WPF:https://learn.microsoft.com/zh-cn/dotnet/fundamentals/runtime-libraries/system-io-filesystemwatcher/*FileSysytemWatcher类介绍用......
  • C# 压缩文件 GZipStream
    //官方文档:https://learn.microsoft.com/zh-cn/dotnet/api/system.io.compression.gzipstream?view=net-8.0/*GZipStream介绍*此类表示gzip数据格式,该格式使用行业标准算法进行无损文件压缩和解压缩。格式包括用于检测数据损坏的循环冗余检查值。gzip数据格式使用与......
  • C# 数据流 FileStream
    //StreamMSHelpManual:https://learn.microsoft.com/zh-cn/dotnet/api/system.io.stream?view=net-8.0//FileStream官方手册:https://learn.microsoft.com/zh-cn/dotnet/api/system.io.filestream?view=net-8.0//StreamWriter:https://learn.microsoft.com/zh-cn/dotne......
  • C# GUI_Async_await异步报告
    //.net8环境WinformnamespaceGUI_Async_await异步报告_供参考_{publicpartialclassForm1:Form{publicForm1(){InitializeComponent();}privatevoidbutton1_Click(objectsender,EventArgse)......
  • YOLOv9有效改进|加入CVPR2020的Bifpn。
    专栏介绍:YOLOv9改进系列|包含深度学习最新创新,助力高效涨点!!!一、论文摘要        Bifpn是RT-DETR中使用的特征提取模块。二、Bifpn模块详解 2.1模块简介       Bifpn: 重复加权双向特征金字塔网络 。本文用于替换YOLOv9中的FPN+PAN结构。三、 ......
  • EXCEL入门,从认识界面开始
    目录一、工作簿和工作表二、功能区和选项卡三、单元格的名称和内容四、区域及选择方法五、对象和上下文选项卡。         六、问题一:有些工作表为什么找不着?二:我的功能区怎么不见了?三:为什么有些功能我的excel里没有?一、工作簿和工作表整个excel文件称为......
  • C# 异步取消
    //.net8WinformusingSystem;usingSystem.Runtime.InteropServices;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;namespaceAsync_Cancell{publicpartialclassForm1:Form{//[1:使用变量控制进程]//staticboolSto......
  • C# 异步控件 backgroundWorker
    //.net4.8WinformusingSystem;usingSystem.Collections.Generic;usingSystem.ComponentModel;usingSystem.Data;usingSystem.Drawing;usingSystem.Linq;usingSystem.Text;usingSystem.Threading.Tasks;usingSystem.Windows.Forms;usingSystem.Threading......
  • AtCoder Beginner Contest 346
    AtCoderBeginnerContest346最刺激的一集。尝试挑战手速极限,用了57s做A。但是好像还是很慢。然后做B,仍然想挑战手速。结果一眼出思路只要把wbwbwwbwbwbw多重复几遍就可以代替「无限长」。很快就写完了。然后交了三发罚时。后来发现我复制若干遍wbwbwwbwbwbw的时候......