#2
zhangcanwei2017-06-25 11:34
|
首先使用 ()获取,存入ds()
然后遍历ds,获取各个信息部分。
Dim ds() As = ()
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
改为(vs2010)的代码,但不中:
可能是红色这行代码不会设置
() '获取,存入ds()
dim s as String , s1 as String
Dim ds() As = ()
For i As Integer = 0 To ds.Length - 1
s= s & ds(i).Name & chr(10) '盘符(驱动器名)
If ds(i).IsReady = True Then
s1=s1 & ds(i).VolumeLabel & chr(10) '卷标
End If
msgbox "s=" & s
msgbox "s1=" & s1
Next
[此贴子已经被作者于2017-6-25 16:57编辑过]