7
VB.Netを使用すると、マップされたすべてのネットワークディレクトリ/ドライブをドロップダウンリストに表示できますか?ドロップダウンリストのすべてのネットワークドライブを取得
私はDropDownListコントロールに追加するには...
VB.Netを使用すると、マップされたすべてのネットワークディレクトリ/ドライブをドロップダウンリストに表示できますか?ドロップダウンリストのすべてのネットワークドライブを取得
私はDropDownListコントロールに追加するには...
をgoggledしているが、役に立つ何かを見つける傾ける:
Private Sub TestCase1()
Dim drive As System.IO.DriveInfo
For Each drive In System.IO.DriveInfo.GetDrives()
If drive.DriveType = IO.DriveType.Network Then
DropDownList1.Items.Add(drive.Name)
End If
Next
End Sub
これは、私はC#でそれを行うだろうかです:
private void TestCase1()
{
//Recurse through the drives on this system and add them to the new DropDownList DropDownList1 if they are a network drive.
foreach(System.IO.DriveInfo drive in System.IO.DriveInfo.GetDrives())
{
//This check ensures that drive is a network drive.
if (drive.DriveType == System.IO.DriveType.Network)
{
//If the drive is a network drive we add it here to a combobox.
DropDownList1.Items.Add(drive);
}
}
}
マイク私はそれがクリックされたときに成長するのを防ぐために何かを追加します。 Good for say .... VBのコンボボックス。
Dim drive As System.IO.DriveInfo
If DropDownList1.Count < 1
For Each drive In System.IO.DriveInfo.GetDrives()
If drive.DriveType = IO.DriveType.Network Then
DropDownList1.Items.Add(drive.Name)
End If
Next
End If