2个回答
展开全部
private void btn_GetDriveInfo_Click(object sender, EventArgs e) { StringBuilder sb = new StringBuilder(); DriveInfo[] myAllDrivers = DriveInfo.GetDrives(); try { foreach (DriveInfo myDrive in myAllDrivers) { if (myDrive.IsReady) { sb.Append("磁盘驱动升卖备器盘符:"); sb.AppendLine(myDrive.Name); sb.Append("磁盘卷标:"); sb.AppendLine(myDrive.VolumeLabel); sb.Append("磁盘类型:"); sb.AppendLine(myDrive.DriveType.ToString()); sb.Append("磁盘格式:"); sb.AppendLine(myDrive.DriveFormat); sb.Append("磁盘吵毁大小:"); sb.AppendLine(myDrive.TotalSize.ToString()); sb.Append("剩余配汪空间:"); sb.AppendLine(myDrive.AvailableFreeSpace.ToString()); sb.Append("总剩余空间(含磁盘配额):"); sb.AppendLine(myDrive.TotalFreeSpace.ToString()); sb.AppendLine("-------------------------------------"); } } } catch (Exception ex) { MessageBox.Show(ex.Message); } txtResult.Text = sb.ToString(); }
展开全部
.net 4的代好兆庆友握码
using System;
using System.IO;
namespace ConsoleTest{
class Test{
static public void Main(String []args)
{
DriveInfo[] drives = DriveInfo.GetDrives();
foreach (DriveInfo info in drives) {
Console.WriteLine(info.Name);
}
Console.ReadKey();
}
}
}
========
C:\猜帆
D:\
E:\
F:\
using System;
using System.IO;
namespace ConsoleTest{
class Test{
static public void Main(String []args)
{
DriveInfo[] drives = DriveInfo.GetDrives();
foreach (DriveInfo info in drives) {
Console.WriteLine(info.Name);
}
Console.ReadKey();
}
}
}
========
C:\猜帆
D:\
E:\
F:\
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询