4
I’m using DriveInfo.GetDrivers()
to take the names of the disk drives present on the machine and list them on a TreeView
.
I made the code below that works, however it does not appear the names of disks in network that my machine has access, only 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 concaten with the drv.VolumeLabel
that networked disks stop appearing (concateno to appear to the user the name of the disk for identification)
I’m thinking of a if
to display them, however the goal was to display the name of the disk in network, because much of the work will be in different networks.
Updating:
I made a If
to correctly display the disk name and display at least the dr letterinet ve
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 middle there is flash drive connected, networked HD and CD-Rom disk in the middle.
When it’s a drive network, the
drv.VolumeLabel
has content or is void?– Maniero
drv.Volumelabel content is "Data".
– Guilherme Golfetto
Did that solve it? I guess that’s what I was thinking.
– Maniero
So, I need to show the user the name of the network drive, instead of the letter, because it’s a lot of letters, take a look at the image I’m going to ask the question.
– Guilherme Golfetto