永发信息网

vb.net获取所有盘符

答案:1  悬赏:40  手机版
解决时间 2021-01-24 09:51
  • 提问者网友:你挡着我发光了
  • 2021-01-24 06:39
怎么用vb.net获取当前计算机已有的盘符,包括可移动磁盘。
最佳答案
  • 五星知识达人网友:怀裏藏嬌
  • 2021-01-24 07:14
首先使用 System.IO.DriveInfo.GetDrives()获取System.IO.DriveInfo,存入ds()
然后遍历ds,获取各个信息部分。
Dim ds() As System.IO.DriveInfo = System.IO.DriveInfo.GetDrives()
For i As Integer = 0 To ds.Length - 1
TextBox1.Text = TextBox1.Text + ds(i).DriveType.ToString + " " '驱动器类型
TextBox1.Text = TextBox1.Text + ds(i).Name + " " '盘符(驱动器名)
TextBox1.Text = TextBox1.Text + ds(i).IsReady.ToString + " " '是否就绪
If ds(i).IsReady = True Then
TextBox1.Text = TextBox1.Text + ds(i).VolumeLabel + " " '卷标
TextBox1.Text = TextBox1.Text + ds(i).TotalSize.ToString + " " '驱动器容量
TextBox1.Text = TextBox1.Text + ds(i).TotalFreeSpace.ToString '驱动器可用容量
End If
TextBox1.Text = TextBox1.Text + vbNewLine
Next
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯