I'm using DriveInfo.GetDrivers()
to get the names of the disk drives present on the machine and list them in TreeView
.
I've made the code below that works, but the network disk names that my machine has access to do not appear, only the local disks.
foreach(DriveInfo drv in DriveInfo.GetDrives())
{
TreeNode node = new TreeNode();
node.ImageIndex = 0;
node.SelectedImageIndex = 0;
node.Text = drv.Name+drv.VolumeLabel;
node.Nodes.Add("");
treeview.Nodes.Add(node);
retorno = true;
}
When I concatenate with drv.VolumeLabel
that the network disks stop appearing (concatenate to appear to the user the name of the disk for identification)
I'm thinking of a if
to display them, but the purpose was to display the name of the networked disk, since much of the work will be on different networks.
Update:
I made a If
to properly display the disk name and display at least the network dr
if (drv.DriveType == DriveType.Network)
node.Text = drv.Name;
else if (drv.DriveType == DriveType.Fixed)
node.Text = drv.Name + drv.VolumeLabel;
else
node.Text = drv.Name;
and is displayed like this:
The problem is that in this environment there is pendrive on, network HD and CD-ROM disk in the middle.