代码
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Collections.Specialized;
using System.Collections.Immutable;
using System.Text;
using System.IO;
namespace ConsoleApp11
{
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Hello World!");
DriveInfo[] driveInfos = DriveInfo.GetDrives();
foreach(DriveInfo drive in driveInfos)
{
Console.WriteLine("drive.Name:" + drive.Name);
//Console.WriteLine("drive.DriveFormat:" + drive.DriveFormat);
Console.WriteLine("drive.DriveType:" + drive.DriveType);
}
Console.ReadKey();
}
}
}
运行结果
此篇博客详细介绍了如何使用C#编程语言通过DriveInfo类遍历计算机上的驱动器,并展示了获取驱动器名称、类型等信息的操作。
540

被折叠的 条评论
为什么被折叠?



